n = int(input()) a = 0 b = 1 % n ans = 1 while b != 0: a, b = b, a + b b %= n ans += 1 print(ans)