import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;


void main() {
    int n;
    scan(n);

    auto a = new int[](n), b = new int[](n);
    auto c = new int[](n), d = new int[](n);

    foreach (i ; 0 .. n) {
        scan(a[i], b[i]);
    }

    foreach (i ; 0 .. n) {
        scan(c[i], d[i]);
    }

    auto adj = new Edge[][](2*n + 2, 0);

    void addEdge(int u, int v) {
        adj[u] ~= Edge(v, 1, adj[v].length.to!int);
        adj[v] ~= Edge(u, 0, adj[u].length.to!int - 1);
    }

    foreach (i ; 0 .. n) {
        addEdge(0, i + 1);
        addEdge(n + i + 1, 2*n + 1);
    }

    foreach (i ; 0 .. n) {
        foreach (j ; 0 .. n) {
            if (a[i] < c[j] && b[i] < d[j]) {
                addEdge(i + 1, n + j + 1);
            }
        }
    }

    int ans = FordFulkerson(adj, 0, 2*n + 1);

    writeln(ans);
}



import std.typecons;
alias Edge = Tuple!(int, "to", int, "cap", int, "rev");
immutable inf = 10^^9 + 7;

int FordFulkerson(Edge[][] adj, int s, int t) {
    int n = adj.length.to!int;
    auto visited = new bool[](n);

    int dfs(int u, int f) {
        if (u == t) {return f;}

        visited[u] = 1;

        foreach (ref e ; adj[u]) {
            if (!visited[e.to] && e.cap > 0) {
                int d = dfs(e.to, min(f, e.cap));

                if (d > 0) {
                    e.cap -= d;
                    adj[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }

        return 0;
    }

    int F;

    while (true) {
        visited[] = 0;
        int f = dfs(0, inf);
        if (!f) break;
        F += f;
    }

    return F;
}



void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
