#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) template using vi = vector; template using vii = vector>; template using viii = vector>; template using viiii = vector>; using P = pair; void chmin(ll & x, ll y) { x = min(x, y); } void chmax(ll& x, ll y) { x = max(x, y); } struct mint { const long long mod = 998244353; long long x; mint(long long x_ = 0) : x((x_% mod + mod) % mod) {} mint& operator+=(const mint& other) { x += other.x; if (x >= mod) x -= mod; return *this; } mint& operator-=(const mint& other) { x -= other.x; if (x < 0) x += mod; return *this; } mint& operator*=(const mint& other) { x *= other.x; x %= mod; return *this; } mint& operator+=(const long long n) { return *this += mint(n); } mint& operator-=(const long long n) { return *this -= mint(n); } mint& operator*=(const long long n) { return *this *= mint(n); } mint& operator=(const mint& other) { x = other.x; return *this; } mint& operator=(const long long n) { x = n % mod; return *this; } bool operator==(const mint& other) const { return x == other.x; } bool operator!=(const mint& other) const { return x != other.x; } mint operator-() const { mint res(mod - x); return res; } mint operator+(const mint& other) const { mint res(x); return res += other; } mint operator-(const mint& other) const { mint res(x); return res -= other; } mint operator*(const mint& other) const { mint res(x); return res *= other; } mint operator+(const long long n) const { mint res(x); mint other(n); return res += other; } mint operator-(const long long n) const { mint res(x); mint other(n); return res -= other; } mint operator*(const long long n) const { mint res(x); mint other(n); return res *= other; } mint pow(long long n) const { if (n == 0) return mint(1); mint res = pow(n / 2); res *= res; if (n % 2) res *= *this; return res; } mint inv() const { return pow(mod - 2); } mint& operator/=(const mint& other) { *this *= other.inv(); return *this; } mint operator/(const mint& other) const { mint res(x); return res /= other; } }; struct combination { vector fact, ifact; combination(int m) :fact(m + 1), ifact(m + 1) { fact[0] = 1; for (int i = 1; i <= m; i++) fact[i] = fact[i - 1] * mint(i); ifact[m] = fact[m].inv(); for (int i = m; i >= 1; i--) ifact[i - 1] = ifact[i] * mint(i); } mint operator()(int n, int k) {//for n<=m, calc nck if (k < 0 || k > n) return mint(0); return fact[n] * ifact[k] * ifact[n - k]; } }; template struct NTT { const int divlim = 23; //when mod is 998244353 vector root, invroot; const mint primitive = 3; NTT() : root(divlim + 1), invroot(divlim + 1) { root[divlim] = primitive.pow((primitive.mod - 1) >> divlim); invroot[divlim] = root[divlim].inv(); for (int i = divlim - 1; i >= 0; i--) { root[i] = root[i + 1] * root[i + 1]; invroot[i] = invroot[i + 1] * invroot[i + 1]; } } void dft(vector& d, const int log, const bool inv = false) { int n = (int)d.size(); if (n == 1 || log == 0) return; vector d0, d1; for (int i = 0; i < n / 2; i++) { d0.push_back(d[2 * i]); d1.push_back(d[2 * i + 1]); } dft(d0, log - 1, inv); dft(d1, log - 1, inv); mint pow = 1, z = (inv ? invroot[log] : root[log]); for (int i = 0; i < n / 2; i++) { d[i] = d0[i] + d1[i] * pow; pow *= z; } for (int i = n / 2; i < n; i++) { d[i] = d0[i - n / 2] + d1[i - n / 2] * pow; pow *= z; } return; } void idft(vector& d, const int log) { dft(d, log, true); return; } vector convolution(vector& f, vector& g) { int n = 1, log = 0, lenf = (int)f.size(), leng = (int)g.size(); while (n < lenf + leng) { n <<= 1; log++; } vector df(n), dg(n); for (int i = 0; i < lenf; i++) df[i] = f[i]; for (int i = 0; i < leng; i++) dg[i] = g[i]; dft(df, log); dft(dg, log); for (int i = 0; i < n; i++) df[i] *= dg[i]; idft(df, log); mint ninv = mint(n).inv(); for (int i = 0; i < n; i++) df[i] *= ninv; return df; } }; int main() { int n; cin >> n; if (n == 1) { cout << 1 << endl; return 0; } vi a(10010); a[1] = a[2] = 1; for (int i = 2; i < 10000; i++) { if (a[i] == 0) { cout << i << endl; return 0; } a[i + 1] = a[i] + a[i - 1]; a[i + 1] %= n; } return 0; }