// 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);
    this.matches = [];
  }

  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 findMatches() {
    var matchCount = 0;

    red.forEach(( thisRed, redi ) => {
      if (!thisRed.taken) {
	thisRed.matches = [];
	blue.forEach(( thisBlue, bluei ) => {
	  if (isFriendly(thisRed, thisBlue)) {
	    matchCount++;
	    thisRed.matches.push(thisBlue)
	  }
	})
      }
    });

    return matchCount > 0;
  }

  var hadMatch;

  do {
    hadMatch = findMatches();

    red.forEach((thisRed, redi) => {
      var bestMatch;
      if (!thisRed.taken) {
	thisRed.matches.forEach((thisMatch) => {
	  if (!thisMatch.taken && (!bestMatch || thisMatch.y < bestMatch.y)) {
	    bestMatch = thisMatch;
	  }
	})
	if (bestMatch) {
	  thisRed.taken = true;
	  bestMatch.taken = true;
	  var removeIndex = blue.indexOf(bestMatch);
	  blue.splice(removeIndex, 1);
	  answer++;
	}

      }
    })

  } while (hadMatch);



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

