N = int(input()) if N == 1: print(1) elif N == 2: print(3) else: F = [0] * (101010) F[1] = F[2] = 1 for n in range(3, 100000): F[n] = (F[n - 1] + F[n - 2]) % N if F[n] == 0: exit(print(n))