n,m=map(int,input().split()) count=0 while 1: count+=1 if n<=m and n>=2 and m>2: print(count) break a=n//2 b=n-a if a%2 or b%2: print(-1) break n=a