import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto A = new long[](N);
    auto B = new long[](N);
    auto C = new long[](N);
    auto D = new long[](N);
    foreach (i; 0 .. N)
        scan(A[i], B[i]);
    foreach (i; 0 .. N)
        scan(C[i], D[i]);
    auto AB = new long[](N);
    auto CD = new long[](N);
    foreach (i; 0 .. N)
    {
        AB[i] = min(A[i], B[i]);
        CD[i] = min(C[i], D[i]);
    }
    zip(AB, A, B).sort();
    zip(CD, C, D).sort();
    long j;
    long ans;
    foreach (i; 0 .. N)
    {
        while (j < N && !(A[i] < C[j] && B[i] < D[j]))
            j++;
        if (j == N)
        {
            writeln(ans);
            return;
        }
        // writefln("%s %s %s %s", A[i], B[i], C[j], D[j]);
        ans++;
        j++;
    }
    writeln(ans);
}
