#include using namespace std; using ll = int_fast64_t; constexpr int mod = 1e9 + 7; constexpr int inf = (1 << 30) - 1; constexpr ll infll = (1LL << 61) - 1; #define fast() ios::sync_with_stdio(false), cin.tie(nullptr) #define set_digit(N) cout << fixed << setprecision((N)) #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") ll func(ll x, ll D) { ll sum = 0; for (int i = 0; x > 0 && sum < D; i++) { sum += x; x /= 2; } return sum; } int main() { ll D; cin >> D; for (ll i = D / 2; i <= D; i++) { if (func(i, D) == D) { cout << i << "\n"; return 0; } } }