program main
      implicit none
      integer :: x
      integer :: i, j
      logical :: flag

      read *, x
      do i = x, 100003
        flag = .true.
        do j = 2, int(sqrt(real(x)+1))
          if ( mod(i,j) == 0 ) then
            flag = .false.
            exit
          end if
        end do
        if ( flag ) then
          print *, i
          stop
        end if
      end do

end program main

      
