program ABC149C
    implicit none
    real::n
    integer::i,Flag
    read*,n
    Flag = 1
    if(n==2) then
        print*,int(n)
        stop
    end if
    if (mod(int(n),2) == 0) then
        n = n + 1
    end if
    do
        Flag = 1
        if (n <= 10) then
            do i = 3,int(n)
                if (mod(int(n),i) == 0) then
                    Flag = 0
                end if
            end do
        else
            do i = 3,int(sqrt(n)),2
                if (mod(int(n),i) == 0) then
                    Flag = 0
                end if
            end do
        end if
        if (Flag == 1) then
            print*,int(n)
            stop
        else
            n = n + 1
        end if
    end do
end program ABC149C
