;; -*- coding:utf-8 -*-

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload :cl-debug-print))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

(defmacro println (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))

(setf *print-circle* t)

(defstruct (edge (:constructor %make-edge))
  (to nil :type fixnum)
  (capacity 0 :type fixnum)
  (flow 0 :type fixnum)
  (reversed nil :type (or null edge)))

(defun add-edge (from to capacity graph)
  (let* ((way (%make-edge :to to :capacity capacity))
         (back (%make-edge :to from :capacity 0 :reversed way)))
    (setf (edge-reversed way) back)
    (push way (aref graph from))
    (push back (aref graph to))))

(defun %calc-flow (src-idx dest-idx graph max-flow checked)
  "DFS"
  (setf (aref checked src-idx) t)
  (if (= src-idx dest-idx)
      max-flow
      (loop for edge in (aref graph src-idx)
            when (and (not (aref checked (edge-to edge)))
                      (< (edge-flow edge) (edge-capacity edge)))
            do (let ((flow (%calc-flow (edge-to edge)
                                       dest-idx
                                       graph
                                       (min max-flow
                                            (- (edge-capacity edge)
                                               (edge-flow edge)))
                                       checked)))
                 (when (> flow 0)
                   (incf (edge-flow edge) flow)
                   (incf (edge-capacity (edge-reversed edge)) flow)
                   (return flow)))
            finally (return 0))))

(defun max-flow (src-idx dest-idx graph)
  (loop with current-flow = 0
        for incr-flow = (%calc-flow src-idx dest-idx graph most-positive-fixnum
                                    (make-array (list (length graph))
                                                :element-type 'boolean
                                                :initial-element nil))
        if (zerop incr-flow)
        do (return current-flow)
        else do (incf current-flow incr-flow)))

;; Hauptteil

(defmacro split-and-bind (arg-lst string &body body)
  (let ((pos1 (gensym "POS"))
	(pos2 (gensym "POS"))
	(str-evaled (gensym "STR")))
    (labels ((expand (arg-lst &optional (init-pos1 t))
	       (if (null arg-lst)
		   body
		   `((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
			    (,pos2 (position #\space ,str-evaled :start ,pos1 :test #'char=))
			    (,(car arg-lst) (parse-integer ,str-evaled :start ,pos1 :end ,pos2)))
		       ,@(expand (cdr arg-lst) nil))))))
      `(let ((,str-evaled ,string))
	 ,@(expand arg-lst)))))

(defun friend-p (x1 y1 x2 y2)
  (and (< x1 x2) (< y1 y2)))
(defun l0 (x1 y1 x2 y2)
  (+ (- x2 x1) (- y2 y1)))

(deftype uint nil `(integer 0 ,(expt 10 9)))
(defun main ()
  (let* ((n (read))
         (red-xs (make-array (list n) :element-type 'fixnum))
         (red-ys (make-array (list n) :element-type 'fixnum))
         (blue-xs (make-array (list n) :element-type 'fixnum))
         (blue-ys (make-array (list n) :element-type 'fixnum))
         (graph (make-array (list (+ 2 n n)) :element-type 'list :initial-element nil))
         (src-idx (+ n n))
         (dest-idx (+ n n 1)))
    (dotimes (idx n)
      (split-and-bind (x y) (read-line)
        (setf (aref red-xs idx) x
              (aref red-ys idx) y)
        (add-edge src-idx idx 1 graph)))
    (dotimes (idx n)
      (split-and-bind (x y) (read-line)
        (setf (aref blue-xs idx) x
              (aref blue-ys idx) y)
        (add-edge (+ idx n) dest-idx 1 graph)))
    (dotimes (red-idx n)
      (dotimes (blue-idx n)
        (when (friend-p (aref red-xs red-idx)
                        (aref red-ys red-idx)
                        (aref blue-xs blue-idx)
                        (aref blue-ys blue-idx))
          (add-edge red-idx (+ n blue-idx) 1 graph))))
    (println (max-flow src-idx dest-idx graph))
    graph))

#-swank(main)


Measured memory_bytes: 17892