! 2019.12.29
!
      program answer
      implicit none
      integer :: X
      integer :: i,j
      integer :: ans
      intrinsic sqrt,mod
!
      read(*,*) X
      i=0
!
      lp1:do
        ans=X+i
        j = 2
        lp2:do
          if(dble(j) > sqrt(dble(ans))) exit lp1
          if(mod(ans,j) == 0) exit lp2
          j = j + 1
        end do lp2
        i=i+1
      end do lp1
      write(*,*) ans
      end program answer