program ABC149C
    implicit none
    integer::X
    integer::i,j
    logical::flag
    read*,X
    do i=X,10**5+3
        flag=.true.
        do j=2,int(sqrt(real(X)+1))
            if(mod(i,j)==0)then
                flag=.false.
                exit
            endif
        end do
        if(flag)then
            print"(i0)",i
            stop
        endif
    end do
end program ABC149C