import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N = in.next().toInt
  val s = new Array[(Int, Int)](N)
  val l = new Array[(Int, Int)](N)

  for(i <- 0 until N) {
    val a, b = in.next().toInt
    s(i) = (a, b)
  }

  for(i <- 0 until N) {
    val c, d = in.next().toInt
    l(i) = (c, d)
  }

  val V = N*2
  val G = Array.fill[List[Int]](V)(Nil) // グラフの隣接リスト表現
  val matching = Array.fill[Int](V)(-1) // マッチングのペア
  val used = new Array[Boolean](V)      // DFSで既に調べたかのフラグ

  // uとvを結ぶ辺をグラフに追加する
  def addEdge(u: Int, v: Int): Unit = {
    G(u) = v :: G(u)
    G(v) = u :: G(v)
  }

  for(a <- 0 until N) {
    val (sx, sy) = s(a)
    for(b <- 0 until N) {
      val (lx, ly) = l(b)
      if (sx < lx && sy < ly)
        addEdge(a, b)
    }
  }

  // 増加パスをDFSで探す
  def dfs(v: Int): Boolean = {
    used(v) = true
    for(i <- 0 until G(v).length) {
      val u = G(v)(i)
      val w = matching(u)
      if(w < 0 || (!used(w) && dfs(w))) {
        matching(v) = u
        matching(u) = v
        return true
      }
    }
    return false
  }

  // 二部グラフの最大マッチングを求める
  def bipartiteMatching(): Int = {
    var res = 0
    for(v <- 0 until V) {
      if(matching(v) < 0) {
        for(i <- 0 until V)
          used(i) = false
        if(dfs(v)) {
          res += 1
        }
      }
    }

    res
  }

  println(bipartiteMatching())
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

