#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple> 
#include <memory>
#include <random>
#include <iterator>

using namespace std;

//------------------------------------------便利型----------------------------------------------
//二次元の点
//#TODO tupleにしてもよい
template <typename T>
struct Point2D
{
	T x;
	T y;

	friend ostream& operator<<(ostream& os, const Point2D<T>& point);
};

ostream& operator<<(ostream& os, const Point2D<int>& point)
{
	os << "(" << point.x << ',' << point.y << ")";
	return os;
}

//長くて読みづらかったのでエイリアステンプレートに
template<class T>
using StdAlloc = std::allocator<T>;

//------------------------------------------便利型----------------------------------------------


//-----------------------------------------便利関数---------------------------------------------
//ユニークな要素数
template <class T>
unsigned long long UniqueElementNum(const vector<T>& data)
{
	auto copy = data;

	sort(begin(copy), end(copy));
	copy.erase(unique(begin(copy), end(copy)), end(copy));

	return copy.size();

	//set<unsigned long long>(begin(copy), end(copy)).size();
}

//最小公倍数
long long gcd(long long a, long long b)
{
	long long c;

	if (a < b) {
		a += b; b = a - b; a -= b;
	}

	while (b != 0) {
		c = a % b;
		a = b;
		b = c;
	}

	return a;
}

//新しい方に対応したい場合、以下を参考にする
//コンテナへ要素を追加
//プリミティブ型など
template<class Num, class Container>
void InitContainer(Num num, Container& container) 
{
	container.resize(num);
	for (auto& d : container) {
		cin >> d;
	}
}

//コンテナへ要素を追加
//Container<Point2D<T>>で特殊化　読みにくい…　マクロにする？
template<class Num, template<class T, class Allocator = StdAlloc<T>> class Container, class T2>
void InitContainer(Num num, Container<Point2D<T2>>& firstContainer)
{
	firstContainer.resize(num);
	for (auto& d : firstContainer) {
		cin >> d.x >> d.y;
	}
}

//コンテナへ要素を追加　を呼び出す処理
template<class Num, class First, class... Rest>
void InitContainer(Num num, First& first, Rest&... rest)
{
	InitContainer(num, first);
	InitContainer(num, rest...);
}

//要素数Nと各要素をコンテナに格納
//コンテナを複数個取れるようにしてみた　テンプレートの練習
template <class Num, class... Container>
void InitNumAndContainer(Num& num, Container&... container)
{
	cin >> num;
	InitContainer(num, container...);
}

//コンテナの内容をstreamへ出力
//今はてきとーにcoutへ改行しながら　果たしてこの書き方は便利なのか…？
//#TODO 引数増やしたりオーバーロード増やしたり
template <template<class T, class Allocator = StdAlloc<T>> class Container, class T>
void ShowContainer(const Container<T>& container)
{
	ostream_iterator<T> outItr(cout, "\n");
	copy(container.begin(), container.end(), outItr);
	cout << endl;
}

//-----------------------------------------便利関数---------------------------------------------


int main() 
{
	////テスト
	//int N = 0;
	//vector<int> test1, test2;
	//InitNumAndContainer(N, test1, test2);

	//ShowContainer(test1);
	//ShowContainer(test2);

	//Pont2D版
	int N = 0;
	vector<Point2D<int>> redPoints, bluePoints;
	InitNumAndContainer(N, redPoints, bluePoints);


	sort(begin(redPoints), end(redPoints), [](const auto& a, const auto& b) {
		return a.y > b.y;
	});

	sort(begin(bluePoints), end(bluePoints), [](const auto& a, const auto& b) {
		return a.x < b.x;
	});

	//ShowContainer(redPoints);
	//ShowContainer(bluePoints);

	vector<tuple<Point2D<int>, bool>> redPointAndIsSelect, bluePoinsAndIsSelect;
	for (const auto& red : redPoints) {
		redPointAndIsSelect.emplace_back(make_tuple(red, false));
	}

	for (const auto& blue : bluePoints) {
		bluePoinsAndIsSelect.emplace_back(make_tuple(blue, false));
	}

	int pairNum = 0;

	for (const auto& blue : bluePoinsAndIsSelect) {
		for (auto& red : redPointAndIsSelect) {
			if (get<1>(red)) {
				continue;
			}

			if (get<0>(blue).x < get<0>(red).x) {
				continue;
			}

			if (get<0>(blue).y < get<0>(red).y) {
				continue;
			}

			get<1>(red) = true;
			pairNum++;
			break;
		}
	}

	cout << pairNum;

	return 0;
}

Measured memory_bytes: 256