#include using namespace std; #define REP(i,n) for (int i = 0; i < (n); ++i) template inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} using ll = long long; using P = pair; using Pl = pair; using veci = vector; using vecl = vector; using vecveci = vector>; using vecvecl = vector>; const int MOD = 1000000007; const double pi = acos(-1); ll gcd(ll a, ll b) {if(b == 0) return a; else return gcd(b,a%b);} ll lcm(ll a, ll b) {return a*b/gcd(a,b);} string d(ll n) { string ans = ""; REP(i,60) { ans += n%2 + '0'; n /= 2; } return ans; } ll f(string S) { ll ans = 0; ll q = 1; REP(i,S.size()) { if(S[i] == '1') ans += q; q *= 2; } return ans; } ll pow(int a, int n) { ll ans = 1; REP(i,n) ans *= a; return ans; } int main() { ll N; cin >> N; if(N == 1) { cout << 1 << endl; return 0; } string S = d(N); //cout << S << endl; vector T(4); ll ans = 0; T[0] = S.substr(0,15); T[1] = S.substr(15,30); T[2] = S.substr(30,45); T[3] = S.substr(45,60); REP(i,4) { vecl res; ll s; if(i == 0) s = 1; else s = 0; for(ll x = s; x < (1LL<<15); x++) { //if(x <= f(T[i])) cout << (x & f(T[i])) << endl; if((x & f(T[i])) == x) { res.push_back(x); } } sort(res.begin(),res.end()); if(res.size() > 0) ans += res[res.size()/2] * pow(2LL,15LL*i); } cout << ans << endl; return 0; }