#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable: 4244) // 最悪をします
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <sstream>
#define BIT(nr) (1UL << (nr))
//#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

//デバッグ用カッコの有無
#ifdef DEBUG
template <class T>ostream &operator<<(ostream &o, const vector<T>&v)
{
	o << "{"; for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? ", " : "") << v[i]; o << "}"; return o;
}
#endif // DEBUG

template <class T>ostream &operator<<(ostream &o, const vector<T>&v)
{
	for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? " " : "") << v[i]; return o;
}

int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位
int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位

int dxp[4] = { 0, 1 }; // x軸方向への変位(正のみ)
int dyp[4] = { 1, 0 }; // y軸方向への変位(負のみ)

using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;

	// libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持
	int rev;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph& g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

namespace atcoder {

	namespace internal {

		template <class T> struct simple_queue {
			std::vector<T> payload;
			int pos = 0;
			void reserve(int n) { payload.reserve(n); }
			int size() const { return int(payload.size()) - pos; }
			bool empty() const { return pos == int(payload.size()); }
			void push(const T& t) { payload.push_back(t); }
			T& front() { return payload[pos]; }
			void clear() {
				payload.clear();
				pos = 0;
			}
			void pop() { pos++; }
		};

	}  // namespace internal

	template <class Cap> struct mf_graph {
	public:
		mf_graph() : _n(0) {}
		mf_graph(int n) : _n(n), g(n) {}

		int add_edge(int from, int to, Cap cap) {
			assert(0 <= from && from < _n);
			assert(0 <= to && to < _n);
			assert(0 <= cap);
			int m = int(pos.size());
			pos.push_back({ from, int(g[from].size()) });
			g[from].push_back(_edge{ to, int(g[to].size()), cap });
			g[to].push_back(_edge{ from, int(g[from].size()) - 1, 0 });
			return m;
		}

		struct edge {
			int from, to;
			Cap cap, flow;
		};

		edge get_edge(int i) {
			int m = int(pos.size());
			assert(0 <= i && i < m);
			auto _e = g[pos[i].first][pos[i].second];
			auto _re = g[_e.to][_e.rev];
			return edge{ pos[i].first, _e.to, _e.cap + _re.cap, _re.cap };
		}
		std::vector<edge> edges() {
			int m = int(pos.size());
			std::vector<edge> result;
			for (int i = 0; i < m; i++) {
				result.push_back(get_edge(i));
			}
			return result;
		}
		void change_edge(int i, Cap new_cap, Cap new_flow) {
			int m = int(pos.size());
			assert(0 <= i && i < m);
			assert(0 <= new_flow && new_flow <= new_cap);
			auto& _e = g[pos[i].first][pos[i].second];
			auto& _re = g[_e.to][_e.rev];
			_e.cap = new_cap - new_flow;
			_re.cap = new_flow;
		}

		Cap flow(int s, int t) {
			return flow(s, t, std::numeric_limits<Cap>::max());
		}
		Cap flow(int s, int t, Cap flow_limit) {
			assert(0 <= s && s < _n);
			assert(0 <= t && t < _n);

			std::vector<int> level(_n), iter(_n);
			internal::simple_queue<int> que;

			auto bfs = [&]() {
				std::fill(level.begin(), level.end(), -1);
				level[s] = 0;
				que.clear();
				que.push(s);
				while (!que.empty()) {
					int v = que.front();
					que.pop();
					for (auto e : g[v]) {
						if (e.cap == 0 || level[e.to] >= 0) continue;
						level[e.to] = level[v] + 1;
						if (e.to == t) return;
						que.push(e.to);
					}
				}
			};
			auto dfs = [&](auto self, int v, Cap up) {
				if (v == s) return up;
				Cap res = 0;
				int level_v = level[v];
				for (int& i = iter[v]; i < int(g[v].size()); i++) {
					_edge& e = g[v][i];
					if (level_v <= level[e.to] || g[e.to][e.rev].cap == 0) continue;
					Cap d =
						self(self, e.to, std::min(up - res, g[e.to][e.rev].cap));
					if (d <= 0) continue;
					g[v][i].cap += d;
					g[e.to][e.rev].cap -= d;
					res += d;
					if (res == up) break;
				}
				return res;
			};

			Cap flow = 0;
			while (flow < flow_limit) {
				bfs();
				if (level[t] == -1) break;
				std::fill(iter.begin(), iter.end(), 0);
				while (flow < flow_limit) {
					Cap f = dfs(dfs, t, flow_limit - flow);
					if (!f) break;
					flow += f;
				}
			}
			return flow;
		}

		std::vector<bool> min_cut(int s) {
			std::vector<bool> visited(_n);
			internal::simple_queue<int> que;
			que.push(s);
			while (!que.empty()) {
				int p = que.front();
				que.pop();
				visited[p] = true;
				for (auto e : g[p]) {
					if (e.cap && !visited[e.to]) {
						visited[e.to] = true;
						que.push(e.to);
					}
				}
			}
			return visited;
		}

	private:
		int _n;
		struct _edge {
			int to, rev;
			Cap cap;
		};
		std::vector<std::pair<int, int>> pos;
		std::vector<std::vector<_edge>> g;
	};

}  // namespace atcoder

int euclidean_gcd(int a, int b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

bool solve() {
	int m, n;
	cin >> m >> n;
	if (m == 0 && n == 0) {
		return false;
	}

	vector<int> b(m), r(n);
	rep(i, m) cin >> b[i];
	rep(i, n) cin >> r[i];

	// [0, m) b [m, m+n) r m+n, m+n+1 s, t
	int s = m + n;
	int t = m + n + 1;
	atcoder::mf_graph<int> g(m + n + 2);

	// s -> b
	rep(i, m) {
		g.add_edge(s, i, 1);
	}
	// r -> t
	rep(i, n) {
		g.add_edge(m + i, t, 1);
	}

	rep(i, m) {
		rep(j, n) {
			int gcd = euclidean_gcd(b[i], r[j]);
			if (gcd == 1) {
				continue;
			}
			g.add_edge(i, m + j, 1);
		}
	}

	int ans = g.flow(s, t);

	cout << ans << "\n";
	return true;
}

signed main() {

	int N;
	cin >> N;
	vector<int> a(N), b(N), c(N), d(N);
	rep(i, N) {
		cin >> a[i] >> b[i];
	}
	rep(i, N) {
		cin >> c[i] >> d[i];
	}

	// [0, N): 赤 [N, 2N-1), 青, 2N: s, 2N+1: t
	int s = 2 * N, t = 2 * N + 1;
	atcoder::mf_graph<int> g(2 * N + 2);

	rep(re, N) {
		rep(bl, N) {
			if (a[re] < c[bl] && b[re] < d[bl]) {
				g.add_edge(re, bl + N, 1);
			}
		}
	}

	rep(i, N) {
		g.add_edge(s, i, 1);
		g.add_edge(i + N, t, 1);
	}

	int ans = g.flow(s, t);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3760