#include using namespace std; using ll = long long; template using vec = vector; template using vvec = vector>; template bool chmin(T& a,T b){if(a>b) {a = b; return true;} return false;} template bool chmax(T& a,T b){if(a=0;i--) #define all(x) (x).begin(),(x).end() #define debug(x) cerr << #x << " = " << (x) << endl; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll D; cin >> D; ll inf = 1e18+10; ll ans = inf; auto calc = [&](int k){ auto val = [&](ll x){ ll sum = 0,now = x; rep(i,k){ sum += now; now /= 2; } return sum; }; ll l = 0,r = inf; while(l+1=D? r:l) = m; } if(val(r)==D) chmin(ans,r); }; rep(i,60) calc(i); cout << ans << "\n"; }