ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2223. So Much Found on the Road...

Time limit: 1.0 second
Memory limit: 256 MB
It is not often that one finds a function on the road, especially one that uses bitwise operations, but Vadim managed to do it. This time he came across the following function:
Python C++
def f(x, y):
    if y == 0:
        return x
    return f(x ^ y, (x & y) << 1)

int f(int x, int y) {
    if (y == 0)
        return x;
    return f(x ^ y, (x & y) << 1);
}
Since this function takes two arguments, Vadim took two numbers X and Y that he had previously found on the road and decided to call f(X,Y) exactly once. However, he does not have any electronics at hand that could execute this code, so he asks for your help. Vadim is not interested in the result of the execution; he needs to know whether this function will ever finish its work, and if so, how many times this function will be called before that. Please answer this question.

Input

The first line contains an integer X in binary representation (1 ≤ X < 21 000 000).
The second line contains an integer Y in binary representation (1 ≤ Y < 21 000 000).

Output

Output “infinity” if the function will run indefinitely with the given arguments; otherwise, output the number of calls to the function f during the single call f(X,Y).

Samples

inputoutput
1011
100
2
101
1
3

Notes

In the C++ function code, int refers to any integer.
Problem Author: Vadim Barinov
Problem Source: Ural Championship 2025