local X = io.read("*n")

for i = X, 10^5+3 do
    local Y = math.ceil(math.sqrt(i))
    local Z = true
    for j = 2, Y do
        if i~=j and i%j==0 then
           Z = false
           break
        end
    end
    if Z then
        print(i)
        break
    end
end