#include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; int main() { FAST_IO auto ans = 0LL; int N; cin >> N; if (N == 1) { cout << 1 << endl; return 0; } i64 x = -1; vector f(N + 1); f[1] = 1; f[2] = 1; for (int i = 3; i <= 10000; i ++) { f[i] = f[i - 1] + f[i - 2]; f[i] %= N; if (f[i] == 0) { if (x < 0) { x = i; } else { x = gcd(x, i); } } } cout << x << endl; }