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