Baekjoon-16953-A to B
27 Sep 2022A,B = map(int, input().split())
infty = int(1e9)
def dfs(x,goal, n):
if x > goal:
return infty
elif x == goal:
return n
else:
return min(dfs(2*x,goal,n+1), dfs(10*x+1,goal,n+1))
ans = dfs(A,B,0)
if ans == infty:
print(-1)
else:
print(ans+1)