// inputに入力データ全体が入る
function Main(input) {
  input = input.split('\n');
  var answer = 0;

  var red = []; 
  var blue = []; 
  var switched = false;

  function Point(x, y) {
    this.x = parseInt(x, 10);
    this.y = parseInt(y, 10);
  }

  for (var i = 1; i < input.length; i++) {
    if (i === parseInt(input[0]) + 1) {
      switched = true;
    }

    if (switched) {
      blue.push(new Point(...input[i].split(' ')));
    } else {
      red.push(new Point(...input[i].split(' ')));
    }
  }

  function isFriendly(red, blue) {
    return red.x < blue.x && red.y < blue.y;
  }


  function getBlueWithSmallestX() {
    var smallest;
    blue.forEach((thisBlue) => {
      if (!smallest || thisBlue.x < smallest.x) {
	smallest = thisBlue;
      }
    })
    blue.splice(blue.indexOf(smallest), 1);
    return smallest;
  }

  function getMatchWithBiggestY(bluePoint) {
    var bestMatch;
    red.forEach((thisRed) => {
      if (isFriendly(thisRed, bluePoint)) {
	if (!bestMatch || thisRed.y > bestMatch.y) {
	  bestMatch = thisRed;
	}
      }
    })
    return bestMatch;
  }


  while (blue.length > 0) {
    var thisBlue = getBlueWithSmallestX();
    var bestMatch = getMatchWithBiggestY(thisBlue);

    if (bestMatch) {
      answer++;
      red.splice(red.indexOf(bestMatch), 1);
    }
  }



  // 出力
  console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

