문제링크 : A->B
import sys
input=sys.stdin.readline
a,b=map(int, input().split())
count=1
while b!=a:
if a>b:
count=-1
break
if b%10==1:
b=b//10
count+=1
else:
if b%2==0:
b=b//2
count+=1
print(count)