eolymp
bolt
Try our new interface for solving problems
Problems

The monkey and the coconuts

The monkey and the coconuts

\includegraphics{https://static.e-olymp.com/content/45/45087a2c235a6a4831e1ae4487e4c0b4b5236565.jpg} To break a coconut, monkey is often used on the roof of \textbf{N}-storey building and throw down coconuts. Once a cute monkey, who are tired of climbing on the roof and decided to find the lowest floor, the drop from which the coconut is broken. The monkey can climb to any floor from \textbf{1} to \textbf{N}-th (the roof is (\textbf{N +1})-th floor) and throw a coconut in the window. If the coconut does not break if dropped, a monkey can use it to experiment again. All in all monkeys for experiments prepared \textbf{K} coconuts. The monkey has to figure out the number of the desired floor, using no more than \textbf{K} coconuts. Also, the monkey wants to find a floor for the minimum number of throws, so it can carry only one coconut, and for every shot she has to go down to the ground prepared for the experiments of coconut or previously abandoned, but not broken coconut. Write a program that will make a plan of experiments, minimizing the number of shots in the worst case. The plan should take into account that the required floor can be any floor from \textbf{1} to \textbf{N}, and it may be that coconut is broken only when falling from the roof. \InputFile The first line of the input file contains two integers, separated by a space - the number of floors \textbf{N} (\textbf{1}  ≤  \textbf{N}  ≤  \textbf{1000000}) and the number of coconuts \textbf{K} (\textbf{1} ≤ \textbf{K} ≤ \textbf{1000}). \OutputFile The first line of the output file display one integer - the minimum number of tests in the worst case.
Time limit 0.5 seconds
Memory limit 64 MiB
Input example #1
10 2
Output example #1
4