from collections import deque N = int(input()) if N==1: print(1) else: flag = -1 for k in range(2,100+1): A = [0]*k A[0] = 1 A = deque(A) for i in range(1,200+1): a = sum(A) if a==N: flag = k break elif a>N:break A.pop() A.appendleft(a) if flag>0:break print(flag)