#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; 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() { int64_t seed; cin >> seed; long long ok = 10000000000; long long ng = -1; while (ng + 1 < ok) { long long m = (ok + ng) / 2; int cnt = 0; x = seed, y = 1, z = 2, w = 3; for (int i = 0; i < 10000001; i++) { long long a = generate(); if (a <= m) cnt++; } if (cnt <= 10000001/2) ng = m; else ok = m; } cout << ok << endl; return 0; }