#include "bits/stdc++.h"
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() {
	int seed;
	while (~scanf("%d", &seed)) {
		x = seed;
		static uint32_t a[10000001];
		int n = 10000001;
		for (int i = 0; i < n; i++) {
			a[i] = generate();
		}
		nth_element(a, a + n / 2, a + n);
		int ans = a[n / 2];
		printf("%d\n", ans);
	}
}