program sample
    implicit none
  
    integer(8) :: i,j,m,n,x,b,s
    
    integer(8):: a(100003)
  
    read(*,*) x
    
    
    do i=1,100003
        a(i)=1
    end do
    a(1)=0
    j=2
    do while(real(j)<=sqrt(real(x)))
       
        if (a(j)==1)then
            do i=1,100003/j
                 a(j*i)=0
            end do
        end if
        j=j+1
    enddo
    do
    if (a(x)==1)then
        write(*,*)x
        stop
    else
        x=x+1
    end if
end do
   


   
       
    
    stop
end program sample
  

