2577 - Naughty fairies

给你一个正整数A,B(a,b<=10^500).要你通过以下三种操作将A变成B。操作分别是 a=a+1 a=a-1 a=2*a 输出最小需要的操作次数

输入

There are several test cases, ended by “0 0”. For each test case, there are only one line containing two numbers separated by a blank, N and M, the original numbers of peaches and the numbers of peaches left(0<N,M<10^500).There is no leading zero.

输出

For each test case, you should output just a number K indicating the minimum time (in minutes) Lily needed to finish her illusion magic.

样例

输入

5 2
1 99
86 32
0 0

输出

2
98
12
时间限制 1 秒
内存限制 128 MB
统计
上一题 下一题