#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector fib = {0,1,1}; for (int i = 1; ; i++){ if (i >= fib.size()){ int f = fib.back() + fib[fib.size()-2]; f %= n; fib.push_back(f); } if (fib[i]%n) continue; int ans = 1; for (int j = 2; j <= i; j++){ if (i%j == 0){ ans = j; } } cout << ans << endl; break; } return 0; }