#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, n) for(int i = 0; i < (n); i++) #define per(i, n) for(int i = (n) - 1; i >= 0; i--) using ll = long long; #define vi vector #define vvi vector #define vl vector #define pii pair #define pll pair #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() constexpr int mod = 1000000007; using namespace std; template bool chmax(T &a, const U &b){ return a < b ? (a = b, 1) : 0; } template bool chmin(T &a, const U &b){ return a > b ? (a = b, 1) : 0; } int main(){ int n; cin >> n; if(!(n & (n - 1))){ cout << "1\n"; return 0; } ll ans = 1e18; for(int i = 1; i < 63; i++){ ll v = (1LL << i) - 1; if(v % n == 0){ cout << "2\n"; return 0; } v++; chmin(ans, v - (v/n*n+1) + 1 + 1); } cout << ans << "\n"; }