#include using namespace std; #define int long long #define rep(i,n) for(int i=0; i<(int)n; i++) #define rep1(i,n) for(int i=1; i<(int)n; i++) #define repa(i,a,n) for(int i=(a); i<(int)(n); i++) #define all(vec) vec.begin(),vec.end() #define COUT(x) cout<<(x)<; using vs = vector; using vvi = vector; using pii = pair; using vpii = vector; const int dx[4] = {1, 0,-1, 0}; const int dy[4] = {0, 1, 0,-1}; int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}} int lcm(int a, int b){return a/gcd(a, b)*b;} template bool chmax(T &a,const T& b){if(a bool chmin(T &a,const T& b){if(a>b){a=b;return true;}return false;} //cout << fixed << setprecision(15); int N, M, K, H, W, X, Y; string S,T; const int INF = 1e18; const int mod = 1e9+7; signed main(){ cin >> N; int ans = N; rep1(i,65){ int l = N/2; int r = N; while(l+1!=r){ int fst = (l+r)/2; int dis = 0; rep(j,i+1){ dis += fst; fst /= 2; } if(dis > N) r = (l+r)/2; else if(dis < N) l = (l+r)/2; else{ chmin(ans, (l+r)/2); break; } } } COUT(ans); return 0; }