#P1582. 倒水

倒水

Description

One day, CC bought NN bottles with effectively infinite capacity, each initially containing 11 liter of water. Then CC found there were too many bottles, so he decided to keep at most KK bottles. Each time, he chooses two bottles that currently contain the same amount of water, pours all the water from one into the other, and then discards the empty bottle. (He cannot discard a bottle that still contains water.)

Obviously, in some cases CC cannot achieve the goal, for example, N=3N = 3, K=1K = 1. In this case, CC will buy some new bottles (the new bottles have infinite capacity and initially contain 11 liter of water) to achieve the goal.

Now CC wants to know the minimum number of new bottles he needs to buy to achieve the goal.

Input Format

One line containing two positive integers N,KN, K (1N2×1091 \le N \le 2 \times 10^9, K1000K \le 1000).

Output Format

A non-negative integer indicating the minimum number of new bottles required.

3 1

1

13 2
3
1000000 5
15808

Hint

Translated by ChatGPT 5