#include #include #include #include #include #include #include #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); ++i) #define all(a) a.begin(), a.end() #define arr(a) a.rbegin(), a.rend() 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 < b){a = b; return true;} return false;} using ll = long long; //Konishii int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll d; cin >> d; ll ans = ll(2e18); for(int i = 0; i <= 70; i++) { ll ok = 0, ng = d + 1; while(ng - ok > 1) { ll mid = (ok + ng) / 2; ll m = mid; ll res = 0; rep(j, i) { res += m; m /= 2; } if(res > d) ng = mid; else ok = mid; }; ll res = 0; ll m = ok; rep(j, i) { res += m; m /= 2; } if(res == d) chmin(ans, ok); } cout << ans << endl; }