#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef unsigned int uint;

const int n=10000001;

uint x, y, z, w;
uint generate() { 
    uint t = (x^(x<<11));
    x = y;
    y = z;
    z = w;
    w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); 
    return w;
}

int main()
{
	uint seed;
	cin>>seed;
	ll c1=0, c2=(1ll<<32)-1;
	while(c1!=c2){
		ll c=(c1+c2+1)/2;
		x=seed, y=1, z=2, w=3;
		int ct=0;
		for(int i=0; i<n; i++){
			uint a=generate();
			if(a<c) ct++;
		}
		if(ct>n/2) c2=c-1;
		else c1=c;
	}
	cout<<c1<<endl;
	return 0;
}