import std.stdio, std.algorithm, std.range, std.conv, std.string;
import core.stdc.stdio;
// foreach, foreach_reverse, writeln

void main() {
	int n;
	scanf("%d", &n);
	int[] x = new int[n*2];
	int[] c = new int[n*2];
	foreach (color; 0..2) {
		foreach (i; 0..n) {
			int a, b;
			scanf("%d%d", &a, &b);
			x[b] = a; c[b] = color;
		}
	}
	int ans = 0;
	int[] set = new int[n*2];
	foreach (y; 0..n*2) {
		if (c[y] == 0) {
			set[x[y]] = 1;
		} else {
			foreach_reverse (i; 0..x[y]) {
				if (set[i]) {
					ans++;
					set[i] = 0;
					break;
				}
			}
		}
	}
	writeln(ans);
}

