Sabzeh with Lentils

View as PDF

Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 977M

Problem type

Parsa's Grandmother has prepared a row of n planting positions, numbered from 1 to n. She wants to plant exactly k lentil seeds in these positions.

At most one seed can be planted in each position.

If two consecutive positions both contain a seed, that creates one adjacent occupied pair. Grandmother wants to place the k seeds so that the number of adjacent occupied pairs is as small as possible.

Compute this minimum possible number.

Input

The input contains two integers, n the number of positions and k, the number of lentil seeds.

Output

Print a single integer: the minimum possible number of adjacent occupied pairs.

Constraints

  • 2 \le n \le 100
  • 1 \le k \le n

Example 1

Input
5 2
Output
0

Example 2

Input
5 4
Output
2

Comments

There are no comments at the moment.