#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include void solve() { int D; std::cin >> D; auto check = [&](long long mid, int k) { long long sum = 0; while (k--) { sum += mid; mid /= 2; } return sum; }; long long res = 1e18; for (int i = 0; i <= log2(D) + 1; i++) { // calc f[x] = D long long l = 0, r = D; while (l < r) { long long mid = l + (r - l + 1) / 2; if (check(mid, i) <= D) l = mid; else r = mid - 1; } if (check(l, i) == D) { res = std::min(l, res); } } std::cout << res << '\n'; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); solve(); return 0; }