PROGRAM main
	implicit none
	integer :: x,xmax, xx
	read *, x
    xmax = 100000000
    do xx = x, xmax
      if (isPrimeNum(xx))then
      	print "(i0)", xx
        exit
       endif
    enddo
contains

	logical pure function isPrimeNum(n)
    	integer, intent (in) :: n
        integer :: i, iend
        
        iend = sqrt(dble(n))+1
        if(iend == n) iend = iend-1
    	isPrimeNum = .false.
        do i = 2 , iend
        	if (mod(n,i)==0) return
        enddo
        
	    isPrimeNum = .true.
    end function isPrimeNum

END PROGRAM main