#include using namespace std; typedef long long ll; ll d; bool ok(ll mid) { ll sum = 0; while (mid) { sum += mid; mid /= 2; if (sum >= d)return true; } return (sum >= d); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> d; ll left = 1, right = 1e18 + 7; for (int rep = 0; rep < 80; rep++) { ll mid = (left + right) / 2; if (ok(mid))right = mid; else left = mid; } cout << right << endl; }