program main
implicit none
integer :: i, j, x, hantei

read(*,*) x
do i = x+1, 1000000
   hantei = 0
   do j = 2, int(sqrt(real(x))) + 1
      if( mod(i,j) == 0 ) then
         hantei = 1
         exit
      end if
   end do
   if( hantei == 0 ) then
      write(*,'(i0)') i
      stop
   end if
end do
end program 
