import scala.io.StdIn
object Main extends App {
  case class Point(x: Int, y: Int)
  def readPoints(n: Int): List[Point] = (0 until n).foldLeft(List.empty[Point]){
    (acc, _)  =>
      val wkp = StdIn.readLine().trim.split(' ').map(_.toInt)
      Point(wkp(0), wkp(1)) :: acc
    }
  
  def comparePoint(red: Point, blue: Point): Boolean = red.x < blue.x && red.y < blue.y
  
  val pointCount = StdIn.readLine().trim.toInt
  val redPoints = readPoints(pointCount).sortBy(e => (e.x, e.y))
  val bluePoints = readPoints(pointCount).sortBy(e => (e.x, e.y))
  
  val wk = redPoints.map{ red =>
    bluePoints.map{ blue =>
      (red, blue)
    }
  }.flatten.filter(e => comparePoint(e._1, e._2)).groupBy(e => e._1).toList.sortBy(l =>l._2.size)
  
  //println(wk)
  val result = wk.foldLeft(0, Set.empty[Point], Set.empty[Point]){ (acc, e) =>
    var cnt = acc._1
    var checkRed = acc._2
    var checkBlue = acc._3
    e._2.foreach{ be =>
      cnt = if(checkRed.contains(e._1) || checkBlue.contains(be._2)){
        cnt
      } else {
        checkRed += e._1
        checkBlue += be._2
        cnt + 1
      }
    }
    
    (cnt, checkRed, checkBlue)

  }

  println(result._1)
}
