s = int(input()) A = 10000001 MOD = 2**32 def gen(): x = s; y = 1; z = 2; w = 3 for i in range(A): t = (x ^ (x << 11)) % MOD x, y, z, w = y, z, w, (w ^ (w >> 19)) ^ (t ^ (t >> 8)) yield w B = A//2 left = 2146000000; right = 2149000000 while left+1 < right: x = s; y = 1; z = 2; w = 3 mid = (left + right) // 2 cnt = 0 for i in range(A): t = (x^(x << 11)) % MOD x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)) if mid < w: cnt += 1 if cnt > B: break if cnt > B: left = mid else: right = mid print(left+1)