/*
                           _________________
                      ____/:::::::::::::::::\_____
                   __/::::::::::::::::::::::::::::\___
                 _/:::::::::::::::::::::::::::::::::::\__
               _/::::::::::::::::::::::::::::::::::::::::\_
              /::::::::::::::::::::::::::::::::::::::::::::\
             |::::::::::::::::::::::::::::::::::::::::::::::\
            /::::::::::::::::::::::::::::::::::::::::::::::::\
           |:::/.:::::::;:::::::::::::::::::::::::::::::::::::|
          /:::/.:::::::/..:::::::::::::::::::::::::::::::::::::\
         |:::|.::::::;/.::::::::::::::::::::::::::::::::::::::::|
         |::/.::::::/..:::::::;;'.::::::::::::::::::::::::::::::|
         |:|.::::/./.::::::;;/..:::::::::::::::::::::::::::::::::|
         `:|.:::|.|.:::::;/..;;;;;;-'.:;;;-':::::::::::::::::::::|
          \|.:::|.|.:::;/.;;/  -..::'''...:::::::::::::::::::::::|
           \;;::|.|.::/.;/--__      |::::::::::::::::::::::::::::|
              \;;\\::/|/ =-__ --_  /::::::::::::::::::::::::::::::
                  \\/    /|  -.   |.::::::::::::::::::::::::::::::
                 _.'    /|'   /=  ||::::::::::::::::::::::::::::::
             _.-'      //'        ||::::::::::::::::::::::::::::::
            (          -          `|::::::::::::::::::::::::::::::
             \                      \:::::::::::::::::::::::::::::
              |  (c)Kolansburg      \::::::::::::::::::::::::::::
             /                      __/:::::::::::::::::::::::::::
             \                   __/::;::;;:::::::::::::::::::::::
             (`                 /;;;;/::|  \::::::::::::::::::::::
             |                 |'_,::::/ \ |::::::::::::::::::::::
            .'                _/::::::/  / /:::::::::::::::. .::::
            |                /.::;;:-'_)/_/::::::::::::::::...::::
 ----.__    |               |.::|   \___/::::::::::::::::::...::::
 :::::::`----\_____          \:::\.-'::::::::::::::::::::::...::::
 ;;;;;:::::::::::::`------     \:::::::::::::::::::::::::::...::::
      `-------:::::::\         /:::::::::::::::::::::::::::...::::
 ___.--------'::::::::\       |::::::::::::::::::::::::::::...::::
 :::::;;;:--:::::::::::|      /::::::::::::::::::::::::::::...::::
 ----'  _,-:.:::::::::::\    |.::::::::::::::::::::::::::::...::::
     __/.::::::::::::::::|   |.::::::::::::::::::::::::::::...::::
  __/.:::;;::::::::;/.:::|   |.::::::::::::::::::::::::::::. .::::
 /.::::;/ /.:::::;/ |.::::|   \_.:::::::::::::::::::::::::::::::::
 :::::/  /.:::::/  /.:::::|     \__.::::::::::::::::::::::::::::::
 ::::|  |.:::::/  /.:::::.|        \,::::::::::::::::::::::::::::
 ::::|  |.::::|   |.:::::/|       __/::::::::::::::::::::::::::::
 \.:::\  \.:::|   |.::::||| __.--::::::::::::::::::::::::::::::::
  \.:::\_ \.:::\   \.:::'/.::::::::::::::::::::::::::::::::::::::
   \.::::\ \.:::\   \.::::::::::::::::::::::::::::::::::::::::::
*/

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <math.h>
#include <stack>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>
 
using namespace std;
 
#define X first
#define Y second

const int MAXN = 5000;

int a[MAXN], b[MAXN], c[MAXN], d[MAXN], n, ans, ma, in;
vector< pair<int, int> > g, gg;
bool used[MAXN];

int main()
{
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> c[i] >> d[i];
		gg.push_back({ c[i], i });
	}
	sort(gg.begin(), gg.end());
	for (int i = 0; i < n; i++)
	{
		in = -1;
		ma = -1;
		for (int j = 0; j < n; j++)
		{
			if (!used[j] && a[j] <= gg[i].X && b[j] <= d[gg[i].Y])
			{
				if (ma < b[j])
				{
					ma = b[j];
					in = j;
				}
			}
		}
		if (in == -1)
			continue;
		ans++;
		used[in] = true;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256