program example
	implicit none
    
    integer(8) :: X,i
    
    read(*,*) X
    
    do i=X,10**5
    
    	if(i==2 .or. i==3) then
    		write(*,*) i
            exit
        else
			if(mod(i,2)/=0 .and. mod(i,3)/=0) then
        		write(*,*) i
                exit
        	end if
        end if
        
    end do
    
end program example