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