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