#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; ll f(ll x, ll N){ ll sum = 0; rep(i,N){ sum += x; x /= 2; } return sum; } int main(){ cin.tie(0); ios::sync_with_stdio(0); ll D; cin >> D; ll ans = D; for(int i=1;i<=70;i++){ ll r = D; ll l = 0; while(r - l > 1){ ll mid = (r + l) / 2; if(f(mid, i) >= D) r = mid; else l = mid; } if(f(r,i) == D) ans = min(ans, r); } cout << ans << endl; }