N, M = map(int, input().split()) fib = [0, 1, 1] for i in range(N - 2): fib.append(fib[-1] + fib[-2]) diff = fib[N] - M if diff < 0: print(-1) elif diff == 0: print(0) else: cnt = 0 for i in range(N, 0, -1): if fib[i] <= diff: diff -= fib[i] cnt += 1 if diff == 0: print(cnt) else: print(-1)