import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

T RD(T)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto N = RD!long;
	
	auto cell = new uint[][](N * 2, N * 2);
	long[2][] b, r;
	foreach (i; 0..N)
	{
		r ~= [RD!long, RD!long];
		cell[r[$-1][0]][r[$-1][1]] = 1;
	}
	foreach (i; 0..N)
	{
		b ~= [RD!long, RD!long];
		cell[b[$-1][0]][b[$-1][1]] = 2;
	}

	auto dp = new long[](N*2);
	long ans;
	foreach_reverse (i; 1..N*2)
	{
		foreach_reverse (j; 1..N*2)
		{
			if (cell[i][j] == 2)
			{
				//stderr.writeln("b ", i, ":", j);
				
				foreach (k; 0..j+1)
					++dp[k];
			}
			if (cell[i-1][j-1] == 1 && dp[j] > 0)
			{
				//stderr.writeln(dp);
				//stderr.writeln(i-1, ":", j-1);
				++ans;
				auto x = dp[j];
				foreach (k; j..N*2)
				{
					if (dp[k] != x) break;

					--dp[k];
				}
				foreach_reverse (k; 0..j)
				{
					--dp[k];
				}
				//stderr.writeln(dp);
			}
		}
	}

	writeln(ans);
	stdout.flush();
}