N = int(input()) import sys if N == 1: print(2) exit() for k in range(2,40): A = [0] i = 1 while True: i += 1 if i < k: A.append(0) elif i == k: A.append(1) else: t = 0 for j in range(1,k + 1): t += A[i-j - 1] if t == N: print(k) exit() elif t > N: break A.append(t) print(-1)