#include // #include using namespace std; // using namespace atcoder; using ll = long long; using ull = unsigned long long; using P = pair; #define rep(i,n) for(ll i = 0;i < (ll)n;i++) #define ALL(x) (x).begin(),(x).end() #define MOD 1000000007 ll calc(ll k,ll l){ ll res = 0; while(l--){ res += k; k >>= 1; } return res; } int main(){ ll d; cin >> d; ll res = 1ll*MOD*MOD; rep(i,70){ ll l = 1,r = 1e18; while(r-l > 1){ ll mid = (l+r)/2; if(calc(mid,i) <= d)l = mid; else r = mid; } if(calc(l,i) == d)res = min(res,l); } cout << res << "\n"; return 0; }