#include #include using namespace std; using namespace atcoder; using ll=long long; using ld=long double; ld pie=3.14159265359; ll inf=10010010010010010; ll mod=998244353; int main(){ ll d; cin >> d; ll ans=inf; for (ll i = 1; i < 60; i++) { ll left=0,right=d+1; while (right-left>1) { ll mid=(right+left)/2; ll x=mid; ll now=0; for (ll j = 0; j < i; j++) { now+=x; x/=2; } if (now>d) { right=mid; }else{ left=mid; } } ll now=0; ll z=left; for (ll j = 0; j < i; j++) { now+=z; z/=2; } if (d==now) { ans=min(ans,left); } } cout << ans << endl; }