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

  var red = []; 
  var blue = []; 
  var switched = false;
  // nums = nums.map((e) => parseInt(e));

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

  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 sortPointFuncBy(prop) {
    return function sortPoints(a, b) {
      if (a[prop] < b[prop]) {
	return -1;
      }
      if (a[prop] > b[prop]) {
	return 1;
      }
      return 0;
    }

  }

  red.sort(sortPointFuncBy('x'));
  blue.sort(sortPointFuncBy('x'));

  red.forEach(( thisRed, redi ) => {
    var matches = blue.filter((thisBlue, i) => {
      if (isFriendly(thisRed, thisBlue)) {
	thisBlue.index = i;
	return true;
      }
    })

    if (matches.length) {
      matches.sort(sortPointFuncBy('y'));
      blue.splice(matches[0].index, 1);
      answer++;
    }

  });



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

