#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

struct Graph{
    struct Node{
        vector<int> inEdges, outEdges;
        vector<int>& edges(bool rev = false){ return rev ? inEdges : outEdges; }
    };
    struct Edge{
        int from, dest;
        ll limit, rem;
        Edge(){ }
        Edge(int from, int dest, ll limit = 1): from(from), dest(dest), limit(limit), rem(limit){ }
        int to(bool rev = false){ return rev ? from : dest; }
        ll remain(bool rev = false){ return rev ? limit - rem : rem; }
        void pour(ll qua, bool rev = false){ rem -= rev ? - qua : qua; }
    };
    vector<Node> nodes;
    vector<Edge> edges;
    Graph(int nn, int en = 10): nodes(nn){
        edges.reserve(max(en, nn));
    }

    void addEdge(int from, int dest, ll limit){
        printd(from, dest);
        nodes[from].outEdges.emplace_back(edges.size());
        nodes[dest].inEdges.emplace_back(edges.size());
        edges.emplace_back(from, dest, limit);
    }
    ll flow(int start, int goal, vector<char>& visited, ll cur){
        if(start == goal){ return cur; }
        auto _flow = [&](bool rev = false){
            for(int eidx : nodes[start].edges(rev)){
                Edge& e = edges[eidx];
                int vidx = e.to(rev);
                if(!e.remain(rev) || visited[vidx]){ continue; }
                visited[vidx] = true;
                ll lim = min(cur, e.remain(rev));
                if((lim = flow(vidx, goal, visited, lim))){
                    e.pour(lim, rev);
                    return lim;
                }
            }
            return 0ll;
        };
        ll ret = _flow();
        return ret ? ret : _flow(true);
    }
    ll maxFlow(int start, int goal){
        if(start == goal){ exit(1); }
        ll ret = 0;
        while(1){
            ll prev = ret;
            vector<char> visited(nodes.size());
            ret += flow(start, goal, visited, MLL);
            if(ret == prev){ break; }
        }
        return ret;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<pair<int, int>> abs(n), cds(n);
    cin >> abs >> cds;
    Graph g(2 * n + 2);
    for(size_t i = 0; i < abs.size(); i++){
        g.addEdge(2 * n, i, 1);
    }
    for(size_t j = 0; j < cds.size(); j++){
        g.addEdge(j + n, 2 * n + 1, 1);
    }
    for(size_t i = 0; i < abs.size(); i++){
        auto& ab = abs[i];
        for(size_t j = 0; j < cds.size(); j++){
            auto& cd = cds[j];
            if(ab.first >= cd.first || ab.second >= cd.second){ continue; }
            g.addEdge(i, j + n, 1);
            printd(i, j);
        }
    }
    cout << g.maxFlow(2 * n, 2 * n + 1) << '\n';
}


Measured memory_bytes: 472