#include "bits/stdc++.h" //#include using namespace std; //using namespace atcoder; int main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); long long d; cin >> d; long long tmp = d / 2 - 100000; for (long long i = tmp; i < tmp + 1000000; i++) { if (i < 0)continue; long long now = i; if (now == d) { cout << i << endl; return 0; } long long a = i; while (a > 0) { now += a / 2; if (now == d) { cout << i << endl; return 0; } a /= 2; } now += a; if (now == d) { cout << i << endl; return 0; } } cout << d << endl; return 0; }