class XORShift def initialize(@x : UInt32) @y = 1u32 @z = 2u32 @w = 3u32 end def generate t = (@x ^ (@x << 11)) @x, @y, @z = @y, @z, @w @w = (@w ^ (@w >> 19)) ^ (t ^ (t >> 8)) end end seed = read_line.to_u32 a = 10000001 puts (UInt32::MIN..UInt32::MAX).bsearch { |x| xor = XORShift.new(seed) (1..a).count { xor.generate <= x } >= (a // 2 + 1) }