#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
#define vv(a,b,c,d) vector<vector<a> >(b,vector<a>(c,d))
#define vvv(a,b,c,d,e) vector<vector<vector<a> > >(b,vv(a,c,d,e))
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Capacity>
struct Dinic {
    struct E {
        int to, rev;
        Capacity cap;
    };
    vector<vector<E>> G;
    vector<bool> used;
    vector<int> level, iter;
    static const Capacity INFW = numeric_limits<Capacity>::max();
    Dinic() {}
    Dinic(int n) : G(n), used(n) {
    }
    void addEdge(int from, int to, Capacity cap) {
        G[from].push_back(E{ to, (int)G[to].size(), cap });
        G[to].push_back(E{ from, (int)G[from].size() - 1 , 0 });
    }

    void bfs(int src, int sink) {
        vector<int> que(G.size());
        int ql = 0, qr = 0;
        que[qr++] = src;
        level.assign(G.size(), -1);
        level[src] = 0;
        while (ql < qr && level[sink] == -1) {
            int u = que[ql++];
            for (auto &e : G[u]) {
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[u] + 1;
                    que[qr++] = e.to;
                }
            }
        }
    }

    Capacity dfs(int v, int t, Capacity f) {
        if (v == t) return f;
        for (int &i = iter[v]; i < G[v].size(); i++) {
            E &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                Capacity d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    Capacity calcMaxFlow(int s, int t) {
        Capacity flow = 0;
        while (1) {
            bfs(s, t);
            if (level[t] < 0)return flow;
            Capacity f;
            iter.assign(G.size(), 0);
            while ((f = dfs(s, t, INFW)) > 0) {
                flow += f;
            }
        }
        return flow;
    }
};

int maxBipartiteMatching(int n, int m, const vector<pair<int,int> > edges) {
    const int source = 0, sink = 1, offN = 2, offM = n + 2;
    const int V = n + m + 2, cap = 1;
    Dinic<int> maxFlow(V);
    for (int i = 0; i < n; ++i) {
        maxFlow.addEdge(source, i + offN, cap);
    }
    for (int i = 0; i < m; ++i) {
        maxFlow.addEdge(i + offM, sink, cap);
    }
    for (auto edge : edges) {
        maxFlow.addEdge(edge.first + offN, edge.second + offM, cap);
    }
    return maxFlow.calcMaxFlow(source, sink);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    // a<c かつ b<d
    vi a(N), b(N), c(N), d(N);
    rep(i, N)cin >> a[i] >> b[i];
    rep(i, N)cin >> c[i] >> d[i];
    vector<pii> kouho;
    rep(i, N)rep(j, N) {
        if (a[i] < c[j] && b[i] < d[j]) {
            kouho.emplace_back(i, j);
        }
    }

    int ans = maxBipartiteMatching(N, N, kouho);
    cout << ans << endl;
}

Measured memory_bytes: 384