program ABC149C
    implicit none
    integer(8)::X,i,j,div_max,flg
    read(5,*)X

    if(X==2)then
        print'(i0)',2
    else
        do i=X,100003
            div_max=int(sqrt(real(i)))+1
            flg=0
            do j=2,div_max
                if(mod(i,j)==0)then
                    flg=1
                    exit
                end if
            end do

            if(flg==0)then
                print'(i0)',i
                exit
            end if
        end do
    end if

end program ABC149C