N,M = list(map(int, input().split())) def fibo(n): numbers = [0 for _ in range(N)] numbers[0] = 1 numbers[1] = 1 for i in range(2,n): numbers[i] = numbers[i-1] + numbers[i-2] return numbers numbers = fibo(N) diff = numbers[N-1] - M if diff == 0: print(0) exit(0) if diff < 0: print(-1) exit(0) count = 0 for i in reversed(range(0,N-2)): if 0 <= diff - numbers[i]: diff = diff - numbers[i] count = count + 1 if diff == 0: break print(count)