#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; uint32_t x = 0, y = 1, z = 2, w = 3; uint32_t generate() { uint32_t t = (x^(x<<11)); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); return w; } int main(void) { ll seed; cin >> seed; int N = 10000001; ll lb = 0, ub = (ll)(UINT32_MAX) + 1; while(ub-lb>1){ ll m = (lb+ub)/2; int n = 0; x = seed; y = 1; z = 2; w = 3; for (int i = 0; i < N; i++) { uint32_t g = generate(); if(g <= m) n++; } if(n <= N/2) lb = m; else ub = m; } cout << ub << endl; return 0; }