local mfl = math.floor
local n = io.read("*n")

local function getprimes(x)
  local primes = {}
  local allnums = {}
  for i = 1, x do allnums[i] = true end
  for i = 2, x do
    if allnums[i] then
      table.insert(primes, i)
      local lim = mfl(x / i)
      for j = 2, lim do
        allnums[j * i] = false
      end
    end
  end
  return primes
end

local t = getprimes(n * 2)
for i = 1, #t do
  if n <= t[i] then
    print(t[i])
    break
  end
end
