//#define NDEBUG
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
constexpr double PI = 3.1415926535897932;

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

void yes(bool c) { puts(c ? "yes" : "no"); }
void Yes(bool c) { puts(c ? "Yes" : "No"); }
void YES(bool c) { puts(c ? "YES" : "NO"); }
void pos(bool c) { puts(c ? "possible" : "impossible"); }
void Pos(bool c) { puts(c ? "Possible" : "Impossible"); }
void POS(bool c) { puts(c ? "POSSIBLE" : "IMPOSSIBLE"); }
template<class T>bool bmaxi(T&a, const T&b) { if (b<a)return 0;a = b;return 1; }
template<class T>bool bmini(T&a, const T&b) { if (a<b)return 0;a = b;return 1; }
template<class T>bool nmaxi(T&a, const T&b) { if (a<b) { a = b;return 1; }return 0; }
template<class T>bool nmini(T&a, const T&b) { if (b<a) { a = b;return 1; }return 0; }
template<typename T>auto scan(T&d)->typename std::enable_if<std::is_signed<T>::value>::type {
	d = 0;int c = fgetc(stdin);bool f = 0;while (c<'0' || '9'<c) { if (c == '-')f = 1;c = fgetc(stdin); }
	while ('0' <= c&&c <= '9') { d = d * 10 + c - '0';c = fgetc(stdin); }if (f)d = -d;
}
template<typename T>auto scan(T&d)->typename std::enable_if<!std::is_signed<T>::value>::type {
	d = 0;int c = fgetc(stdin);while (c<'0' || '9'<c)c = fgetc(stdin);
	while ('0' <= c&&c <= '9') { d = d * 10 + c - '0';c = fgetc(stdin); }
}
template<>void scan(char&d) { d = fgetc(stdin);while (d<'a' || 'z'<d)d = fgetc(stdin); }
template<>void scan(double&d) { scanf("%lf", &d); }
template<>void scan(std::string&d) {
	d.clear();int c = fgetc(stdin);
	while (c<'a' || 'z'<c)c = fgetc(stdin);while ('a' <= c&&c <= 'z') { d.push_back(c);c = fgetc(stdin); }
}
template<typename F, typename...R>void scan(F&f, R&...r) { scan(f);scan(r...); }
template<typename T>T input() { T d;scan(d);return d; }

using namespace std;
constexpr int inf = 1 << 29;

struct max_flow {
	struct edge { int to, cap, rev; };
	int V;
	vector<vector<edge>> G;
	vector<int> itr, level;

	max_flow(int V) : V(V) { G.assign(V, vector<edge>()); }

	void add_edge(int from, int to, int cap) {
		G[from].push_back({ to, cap, (int)G[to].size() });
		G[to].push_back({ from, 0, (int)G[from].size() - 1 });
	}

	void bfs(int s) {
		level.assign(V, -1);
		queue<int> q;
		level[s] = 0; q.push(s);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			for (auto &e : G[v]) {
				if (e.cap > 0 && level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}

	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int& i = itr[v]; i < (int)G[v].size(); ++i) {
			edge& e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int run(int s, int t) {
		int ret = 0, f;
		while (bfs(s), level[t] >= 0) {
			itr.assign(V, 0);
			while ((f = dfs(s, t, inf)) > 0) ret += f;
		}
		return ret;
	}
};

int main(void) {
	uint32 n;
	scan(n);
	max_flow G(2 * n+2);
	std::vector<uint32> a(n), b(n), c(n), d(n);
	for (uint32 i = 0;i < n;++i)scan(a[i], b[i]);
	for (uint32 i = 0;i < n;++i)scan(c[i], d[i]);
	for (uint32 i = 0;i < n;++i) {
		for (uint32 j = 0;j < n;++j) {
			if ((a[i] < c[j]) && (b[i] < d[j])) {
				G.add_edge( j,i+n,1 );
			}
		}
	}
	for (uint32 i = 0;i < n;++i) {
		G.add_edge( 2 * n,i,1 );
		G.add_edge( n + i,2 * n + 1,1 );
	}
	int ans = G.run(2 * n, 2 * n + 1);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384