N = int(input()) x, y = 0, 1 % N now = 0 while True: now += 1 x, y = y, (x + y) % N if x == 0: print(now) exit()