Sabzeh with Lentils
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≤n≤100
- 1≤k≤n
Example 1
5 2
0
Example 2
5 4
2
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.