题目描述
Problem Description
You want to measure the weight of an object in 1 g units using a balance scale.
You can prepare $N$ types of weights, each in the quantity of $K$. Here, the $i$th ($1 \leq i \leq N$) type of weight has the same weight.
You can place these $N \times K$ weights on
- The right pan of the balance
- The left pan of the balance
- Neither pan
When you place the object to be weighed on the right pan,
(Total weight of weights on the left pan) = (Total weight of weights on the right pan) + (Weight of the object)
The balance will be balanced, and at this time, the weight of the object can be measured as (Total weight of weights on the left pan) - (Total weight of weights on the right pan) g.
You want to measure all weights from 1 g to $M$ g in 1 g units with the least number of weight types. Output the minimum number of weight types $N$ required.
Input Format
The input is given from the standard input in the following format:
$M$ $K$
Output Format
Output the minimum number of weight types $N$.
Sample Input and Output
Sample Input #1
5 1
Sample Output #1
3
Sample Input #2
8 2
Sample Output #2
2
Notes/Hints
Constraints
- $1 \leq M \leq 10^9$
- $1 \leq K \leq 10^5$
- All inputs are integers.
Sample Explanation 1
For example, if you prepare weights of 1 g, 2 g, and 3 g, you can measure:
- 1 g by placing a 1 g weight on the left pan
- 2 g by placing a 2 g weight on the left pan
- 3 g by placing a 3 g weight on the left pan
- 4 g by placing 2 g and 3 g weights on the left pan and a 1 g weight on the right pan
- 5 g by placing 2 g and 3 g weights on the left pan
It is not possible to measure 1 g to 5 g with only 2 types of weights, so this is the minimum.
Sample Explanation 2
For example, preparing weights of 1 g and 3 g is sufficient.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分