"use strict"

const main = arg => {
  arg = arg.trim().split("\n");
  const N = parseInt(arg[0]);

  arg = arg.slice(1, -1).map(n=>n.split(" ").map(l=>parseInt(l))).map(xy => {
    return {x: xy[0], y: xy[1]}
  });

  const red  = arg.slice(0, N);
  const blue = arg.slice(N);
  const paired = [...Array(N)].fill(0);

  blue.sort((a, b) => a.x - b.x);

  for (let i=0; i<N; i++) {
    let max_y = -1;
    let idx = '';

    for (let j = 0; j < N; j++) {
      if(red[j].x >= blue[i].x) continue;
      if(red[j].y >= blue[i].y) continue;
      if(paired[j] === 1)       continue;
      if(max_y >= red[j].y)     continue;

      max_y = red[j].y;
      idx = j;
    }

    if (idx !== '') paired[idx] = 1;
  }

  const ans = paired.filter(n => n === 1).length;

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
