## https://yukicoder.me/problems/no/702 import heapq MAX = 2 ** 32 - 1 class Generator: def __init__(self, seed): self.x = seed self.y = 1 self.z = 2 self.w = 3 def generate(self): t = (self.x ^ (self.x << 11)) & MAX self.x = self.y self.y = self.z self.z = self.w self.w = ((self.w ^ (self.w >> 19)) ^ (t ^ (t >> 8))) & MAX return self.w def solve(N, seed, value): generator = Generator(seed) n2 = N // 2 n1 = n2 + 1 cnt = 0 for _ in range(N): x = generator.generate() if x >= value: cnt += 1 return cnt >= n1 def main(): seed = int(input()) N = 10000001 low = 0 high = 2 ** 32 - 1 while high - low > 1: mid = (high + low ) // 2 if solve(N, seed, mid): low = mid else: high = mid if solve(N, seed, high): print(high) else: print(low) if __name__ == "__main__": main()