Vitaliy wants to buy exactly cakes. He has two purchasing options:
Buy cake for coin.
Buy k+1 cakes for coins.
Determine the minimum number of coins Vitaliy needs to spend to purchase exactly cakes.
The input consists of a single line containing two integers and (1 \le n, k \le 10^{18}), where is the number of cakes to be purchased and is the number of coins required for the second type of purchase.
Output a single integer representing the minimum number of coins needed to buy exactly cakes.
Example 1
Example 2
In the first example, Vitaliy can buy 3 cakes for 2 coins and then buy 1 cake twice for 1 coin each. This results in a total of 2 + 1 + 1 = 4 coins.
In the second example, Vitaliy can simply buy 1 cake for 1 coin.
Solutions that correctly handle the constraints 1 \le n, k \le 10^5 will earn 20% of the total points.