n = int(input()) for k in range(2, 70): A = [0] * (k - 1) + [1] while A[-1] < n: A.append(sum(A[-k:])) if n in A: print(k) exit() print(-1)