eolymp
bolt
Try our new interface for solving problems
Problems

Chernobyl’ Eagle on a Roof

Chernobyl’ Eagle on a Roof

Once upon a time an Eagle made a nest on the roof of a very large building. Time went by and some eggs appeared in the nest. There was a sunny day, and Niels Bohr was walking on the roof. He suddenly said: “Oops! All eggs surely have the same solidity, thus there is such non-negative number \textit{\textbf{E}} that if one drops an egg from the floor number \textit{\textbf{E}}, it will not be broken (and so for all the floors below the \textit{\textbf{E}}-th), but if one drops it from the floor number \textit{\textbf{E}}+\textbf{1}, the egg will be broken (and the same for every floor higher, than the \textit{\textbf{E}}-th).” Now Professor Bohr is going to organize a series of experiments (i.e. drops). The goal of the experiments is to determine the constant \textit{\textbf{E}}. It is evident that number \textit{\textbf{E}} may be found by dropping eggs sequentially floor by floor from the lowest one. But there are other strategies to find \textit{\textbf{E}} for sure with much less amount of experiments. You are to find the least number of eggs droppings, which is sufficient to find number \textit{\textbf{E}} for sure, even in the worst case. Note that dropped eggs that are not broken can be used again in following experiments. The floors are numbered with positive integers starting from \textbf{1}. If an egg has been broken being dropped from the first floor, you should consider that \textit{\textbf{E}} is equal to zero. If an egg hasn’t been broken even being dropped from the highest floor, consider that \textit{\textbf{E}} is also determined and equal to the total number of floors. \InputFile Input contains multiple (up to 1000) test cases. Each line is a test case. Each test case consists of two numbers separated with a space: the number of eggs, and the number of floors. Both numbers are positive and do not exceed 1000. Tests will end with the line containing two zeroes. \OutputFile For each test case output in a separate line the minimal number of experiments, which Niels Bohr will have to make even in the worst case.
Time limit 1 second
Memory limit 64 MiB
Input example #1
1 10
2 5
0 0
Output example #1
10
3
Author A.Klepinin, N.Shamgunov
Source The Seventh Ural State University collegiate programming contest