#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

class HopcroftKarp {
    vector<vector<ll> > G;
    vll pU, pV, dist;
    ll Nl, Nr, N;
    HopcroftKarp(){}
    bool bfs(ll m) {
        queue<ll> q;
        for(int u = 1; u <= m; u++) {
            if(pU[u]==0) {
                dist[u] = 0;
                q.push(u);
            }else {
                dist[u] = INF;
            }
        }
        dist[0] = INF;
        while (!q.empty())
        {
            ll u = q.front();q.pop();
            if(dist[u] < dist[0]) {
                for(auto &v:G[u]) {
                    if(dist[pV[v]] == INF) {
                        dist[pV[v]] = dist[u] + 1;
                        q.push(pV[v]);
                    }
                }
            }
        }
        return dist[0] != INF;
    }
    bool dfs(ll u) {
        if(u != 0) {
            for(auto &v:G[u]) {
                if(dist[pV[v]] == dist[u] + 1 && dfs(pV[v])) {
                    pV[v] = u;
                    pU[u] = v;
                    return true;
                }
            }
            dist[u] = INF;
            return false;
        }
        return true;
    }
public:
    HopcroftKarp(ll _Nl, ll _Nr) {
        Nl = _Nl;
        Nr = _Nr;
        N = Nl + Nr;
        G.resize(N+2);
        pU.resize(Nl+1);
        pV.resize(Nr+1);
        dist.resize(N+2);
    }
    void initialize(ll _Nl, ll _Nr) {
        Nl = _Nl;
        Nr = _Nr;
        N = Nl + Nr;
        G.clear();
        G.resize(N+2);
        pU.assign(Nl+1, 0);
        pV.assign(Nr+1, 0);
        dist.assign(N+2, 0);
    }
    void unite(ll u, ll v) {
        if(u == 0 || v == 0) {
            debug("Warning: 0-indexed");
        }
        G[u].push_back(v);
        G[Nl+v].push_back(u);
    }
    ll bipartite_matching() {
        pU.assign(Nl, 0);
        pV.assign(Nr, 0);
        ll ret = 0;
        while(bfs(Nl)) {
            for(int u=1; u <= Nl; u++) {
                if(pU[u] == 0 && dfs(u)) {
                    ret++;
                }
            }
        }
        return ret;
    }
};

void solve() {
    ll N;
    cin >> N;
    vll a(N), b(N), c(N), d(N);
    HopcroftKarp g(N, N);
    REP(i, N) cin >> a[i] >> b[i];
    REP(i, N) cin >> c[i] >> d[i];
    REP(i, N){
        REP(j, N) {
            if(a[i] < c[j] && b[i] < d[j]) {
                g.unite(i+1, j+1);
            }
        }
    }
    out(g.bipartite_matching());
}

int main() {
    fast_io;
    solve();
    return 0;
}


Measured memory_bytes: 384