#P7494. 三遣救援

三遣救援

Description

One morning, Muro found that a piece of cake he had secretly kept was eaten! He immediately guessed that one of the pigs had eaten the cake, so he rushed to the pigsty to find that pig and punish it.

There are nn pigs in the pigsty, numbered with integers from 11 to nn. Except for the pig that ate the cake, all other pigs have the same weight, and the pig that ate the cake is slightly heavier than the others (you may assume the pigs were originally 5kg5\text{kg}, and the one that ate the cake is 5.1kg5.1\text{kg}). Muro cannot tell by sight which pig ate the cake.

Fortunately, Muro has a balance scale. He can drive pigs onto the two sides of the scale to compare which side is heavier. However, this scale is not very large: each side can hold at most mm pigs, otherwise the scale will be damaged and become unusable (the pig that ate the cake will not reduce the number of pigs that can be placed on one side, i.e., whether or not a pig ate the cake, each side can still hold at most mm pigs).

Muro does not want to spend too much time, so he wants to know, under the condition that the scale is not damaged, at least how many weighings are needed to guarantee finding the pig that ate the cake. Please compute this number.

Input Format

One line with two positive integers n,mn,m.

Output Format

One line with one positive integer, the answer.

4 5
2
13 6
3
8 2
3
114 514
5
19198 10
962

Hint

Explanation for Sample 1:

Muro first puts pig 11 and pig 22 onto the two sides of the scale respectively, then puts pig 33 and pig 44 onto the two sides respectively. In this way, he can definitely find the pig that ate the cake, and the number of weighings is 22. Obviously, using the scale only once cannot guarantee finding the pig that ate the cake.

Explanation for Sample 3:

Each side of the scale can hold at most 22 pigs, so at least 33 weighings are needed to guarantee finding it.


Constraints

This problem uses bundled testdata.

  • Subtask 1 ( 10%10\% ): n,m10n,m\leq10.
  • Subtask 2 ( 25%25\% ): n,m106n,m\leq10^6.
  • Subtask 3 ( 15%15\% ): nmn\leq m.
  • Subtask 4 ( 50%50\% ): no special constraints.

For all testdata, 1n,m10151\leq n,m\leq10^{15}.

Translated by ChatGPT 5