P27683 [洛谷] Courage
普及+
题目描述

Problem Background

The virtue of mathematicians in seeking the beauty of truth, the source of unceasing strength — Courage.

"The Light of Courage," Joy, is the successor to the Duov tribe's chieftain and a warrior endowed with the ancient war god's power.

Problem Description

Joy has a skill that can enhance the attack power of $x$ to $x^2$. However, this skill is not perfect; after the first use, the attack power decreases to half of its previous value before each subsequent use of the skill.

For example, if the initial attack power is $\color{red}6$, it becomes $6^2=\color{red}{36}$ after enhancement. Before the next enhancement, it first decays to $36/2=18$, and then it is enhanced to $18^2=\color{red}{324}$.

Joy wants to know how many enhancements are needed, starting with an initial attack power of $x$, to make it at least $2^n$. If it is impossible to reach the requirement no matter how many enhancements are made, output inf.

Input Format

A line containing two positive integers $x$ and $n$. $x$ represents the initial attack power, and $n$ represents the power level to reach $2^n$.

Output Format

A line containing an integer or the string inf, representing the answer.

Sample Input and Output

Sample Input #1

2 1

Sample Output #1

0

Sample Input #2

3 6

Sample Output #2

3

Sample Input #3

16 335

Sample Output #3

7

Notes

Sample 1 Explanation:
The initial attack power $x=2$ already meets the requirement of $2^n=2$, so no skill is needed, and the answer is $0$.

Sample 2 Explanation:
The initial attack power is $3$, and it needs to reach $2^6=64$. After the first skill use, it becomes $9$, after the second, it becomes $(9/2)^2=81/4$, and after the third, it becomes $((81/4)/2)^2=6561/64$, which meets the requirement, so the answer is $3$.

Data Range:
This problem is group-tested.

Subtask 1 (15 pts): $n\le 60$;
Subtask 2 (20 pts): $x=4$;
Subtask 3 (25 pts): $n\le 10^5$;
Subtask 4 (40 pts): No special restrictions.

For all data, $2\le x\le 10^9$, $1\le n \le 10^9$.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 1
样例输出
0