Be Like Hasib
Hasib, the famous programmer, uses a little game when he teaches Binary Search to his students. He requests them to guess a number between 1 to 100, and then he asks a few questions to them. After his students answer those questions, Hasib magically shouts the predicted number correctly!
But how does he do it? What are those questions that makes him so sure about the predicted number? Well, here’s an example. Let’s assume that the predicted number is 22. So Hasib and his student will have a conversation similar to this:
Hasib: Is your number greater than 50?
Hasib: Is your number greater than 25?
Hasib: Is your number greater than 13?
Hasib: Is your number greater than 19?
Hasib: Is your number greater than 22?
Hasib: Is your number greater than 21?
Hasib: (shouts) Then the number you’ve guessed must be 22!
Let’s take a closer look at Hasib’s technique. Initially, the number is guessed anywhere from 1 to 100. After the first question, Hasib realizes that the guessed number can not be within 51 to 100. So he eliminates this range. His new range becomes from 1 to 50. After the second question, he further eliminates the range from 26 to 50. Thus, after every question, he crosses out about 50 percent of his current range. Eventually, his range starts and ends at the same position, and he becomes sure of the guessed number.
You now want to write an automated system that would mimic Hasib’s magical way of reading people’s mind! Instead of letting people guess a number from 1 to 100, you let people guess a number from 1 to N. You will have to determine, given N and X, that how many questions your system needs to ask ( or Hasib would have asked ) in order to guess the number X correctly.
The only line of the input contains two integers N ( 1 ≤ N ≤ 1018 ) and X ( 1 ≤ X ≤ N ).
Output an integer, the number of questions Hasib would ask if someone guesses a number X between 1 and N.
TarifEzazTarif studied at North South University. He loves sport programming contests. When he is not solving problems himself, he is training others to do it. →