local x = io.read("n")
if x <= 2 then
    print(2)
    return
end
local primes = {2}
for n=3,100003,2 do
    local isprime = true
    for _, p in ipairs(primes) do
        if p * p > n then
            break
        end
        if n % p == 0 then
            isprime = false
            break
        end
    end
    if isprime then
        primes[#primes + 1] = n
        if n >= x then
            print(n)
            return
        end
    end
end