#include using namespace std; #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } #define rep(i,n) for (int i = 0; i < (n); ++i) typedef long long ll; using P = pair; const int INF=1001001001; const int mod =1e9+7; ll f(ll x,ll k){ ll sum=0; while(k--){ sum+=x; x/=2; } return sum; } int main() { ll d;cin>>d; ll ans=1e18+5; for(int k=0;k<=log2(d)+1;k++){ ll l=0,r=d; while(r-l>1){ ll mid=(l+r)/2; if(f(mid,k)>=d){r=mid;} else{l=mid;} } if(f(r,k)==d){chmin(ans,r);} } cout<