import sys input=lambda: sys.stdin.readline().rstrip() n,m=map(int,input().split()) A=[1,1] for i in range(n-2): A.append(A[-1]+A[-2]) import bisect ans=0 nn=A[-1] while nn-m>0: d=nn-m if d==1: m+=1 ans+=1 break else: m+=A[bisect.bisect_left(A,d)-1] ans+=1 if nn!=m: print(-1) else: print(ans)