program ccc
implicit none

integer(8) :: x, i, j, count

read*, x
x = x - 1

do i = 1, 10000
	x = x + 1
    count = 0
	do j = 2, x-1
	    if (mod(x,j)==0) then
    	count = 1
    	exit
    	end if
    end do
    if (count==0) then
	print*, x
   	return
   	end if
end do

end program