// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

#define ALL(obj) (obj).begin(),(obj).end()

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>

#define pb(a) push_back(a)
#define mp make_pair

class FordFulkerson{//最大流(最小カット)を求める 辺の形式に注意
  public:
  FordFulkerson(vector<M> ed,int n);
  int Dfs(int v,int t,int f);
  ll Solve(int s,int t);
  int pnum;
  vector<M> edges;
  V flag;
};

FordFulkerson::FordFulkerson(vector<M> ed,int n){
  pnum=n;
  edges=ed;
}

int FordFulkerson::Dfs(int s,int t,int f){
  if(s==t)return f;
  flag[s]=true;
  FOREACH(e,edges[s]){
    if(!flag[e.first] && e.second>0){
      int d = Dfs(e.first,t,min(f,e.second));
      if(d>0){
        e.second-=d;
        edges[e.first][s]+=d;
        return d;
      }
    }
  }
  return 0;
}

ll FordFulkerson::Solve(int s,int t){
  ll ret=0;
  while(1){
    flag=V(pnum,0);
    int f=Dfs(s,t,INF);
    if(!f)return ret;
    ret+=f;
  }
}
#define MAX 10000
struct edge { int to, cap, rev; };
vector<edge> G[MAX];
bool used[MAX];

void add_edge(int from, int to, int cap) {
    G[from].push_back((edge){to, cap, int(G[to].size())});
    G[to].push_back((edge){from, 0, int(G[from].size()-1)});
}

int dfs(int v, int t, int f) {
    if(v == t) return f;
    used[v] = 1;
    for(int i = 0 ; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(used[e.to] or e.cap <= 0) continue;
        int 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;
}

int ford_fulkerson(int s, int t) {
    int flow = 0, f;
    while(1){
        memset(used, 0, sizeof(used));
        f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int main(){
  CIN(n);VC2(n,a,b);VC2(n,c,d);
  vector<M> ed(2*n+2);//0-1
  V taiou(n);
  V taiou2(n);
  REP(i,n)taiou[i] = i+2;
  REP(i,n)taiou2[i] = i+2+n;
  REP(i,n){
    add_edge(0,taiou[i],1);
    add_edge(taiou2[i],1,1);
    ed[0][taiou[i]]=1;
    ed[taiou[i]][0]=1;
    ed[taiou2[i]][1]=1;
    ed[1][taiou2[i]]=1;
  }
  REP(i,n)
    REP(j,n){
      if(a[i]<c[j] && b[i] < d[j]){
        add_edge(taiou[i],taiou2[j],1);
        ed[taiou[i]][taiou2[j]]=1;
        ed[taiou2[j]][taiou[i]]=1;
      }
    }

  COUT(ford_fulkerson(0,1));
  /*
  ENDL;
  int i=0;
  FOREACH(xx,ed){
    cout<<i<<" : ";
    i++;
    FOREACH(xxx,xx){
      SCOUT(xxx.first);
    }
    ENDL;
  }

  FordFulkerson calc(ed,2*n+2);
  int ans = calc.Solve(0,1);
  COUT(ans);
  */


  return 0;
}


Measured memory_bytes: 896