N,M = map(int,raw_input().split()) fib = [0]*N fib[0]=fib[1]=1 for i in xrange(2,N):fib[i] = fib[i-1] + fib[i-2] dp = {0:0} for i in xrange(3,N): x = fib[N-i] tmp_dp = {} for k,v in dp.iteritems(): tmp_dp[k] = v nk = k+x if nk not in tmp_dp or tmp_dp[nk] > v+1: tmp_dp[nk] = v+1 dp = tmp_dp k = fib[N-1] - M print dp[k] if k in dp else -1