program ABC149C
    implicit none
    integer(8)::n,i,Flag
    read*,n
    do
        Flag = 1
        do i = 2,n-1
            if (mod(n,i) == 0) then
                Flag = 0
            end if
        end do
        if (Flag == 1) then
            print*,n
            stop
        else
            n = n + 1
        end if
    end do
end program ABC149C