n = int(input()) x = y = 1 % n i = 1 while x: x, y = y, (x + y) % n i += 1 print(i)