n = int(input()) for j in range(2, 100) : f = [0] * j + [1] for k in range(150) : f.append(sum(f[-j:])) if n in f : print(j) exit() print(-1)