#include using namespace std; typedef long long ll; ll d; ll ok(ll mid, int k) { ll sum = 0; while (k--) { sum += mid; mid /= 2; } return sum; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> d; ll ans = 1e18; for (int i = 0; i < 68; i++) { ll left = 0, right = d; for (int rep = 0; rep < 60; rep++) { ll mid = (left + right) / 2; ll got = ok(mid, i); if (got >= d)right = mid; else left = mid; } if (ok(right, i) == d) { ans = min(ans, right); } } cout << ans << endl; }