/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <ext/random>
#include <ext/rope>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
template<typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  os << '{';
  for (size_t i = 0; i < vec.size(); ++i) {
    os << vec[i];
    if (i != vec.size() - 1) os << ',';
  }
  os << '}';
  return os;
}
template<typename T, typename U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '{' << p.first << " " << p.second << '}';
}
// constant
constexpr int INF = (1<<30) - 1;  // 1.073741823e9
constexpr int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
constexpr int MOD = 1000000007;

template<typename T>
class Dinic {
 public:
  Dinic(const int& node_size) : node_size_(node_size) { Initialize(); }
  void AddEdge(const int& from, const int& to, const T& cost);
  T MaxFlow(const int& s, const int& t);

 private:
  struct edge {
    int to;
    T cap;
    int rev;
  };
  int node_size_;
  std::vector<std::vector<edge>> graph_;
  std::vector<int> level;
  std::vector<int> iter; 
  void Initialize();
  void BFS(const int& s);
  T DFS(const int& v, const int& t, const int& f);
};

template<typename T>
void Dinic<T>::Initialize() {
  graph_.resize(node_size_);
  level.assign(node_size_, 0);
  iter.assign(node_size_, 0);
}

template<typename T>
void Dinic<T>::AddEdge(const int& from, const int& to, const T& cap) {
  graph_[from].push_back({to, cap, static_cast<int>(graph_[to].size())});
  graph_[to].push_back({from, static_cast<T>(0), static_cast<int>(graph_[from].size()) - 1});
}

template<typename T>
void Dinic<T>::BFS(const int& s) {
  std::fill(level.begin(), level.end(), -1);
  std::queue<int> q;
  level[s] = 0;
  q.push(s);
  while (!q.empty()) {
    int top = q.front(); q.pop();
    for (const edge& next : graph_[top]) {
      if (next.cap > 0 && level[next.to] < 0) {
        level[next.to] = level[top] + 1;
        q.push(next.to);
      }
    }
  }
}

template<typename T>
T Dinic<T>::DFS(const int& v, const int& t, const int& f) {
  if (v == t) return f;
  for (int& i = iter[v]; i < graph_[v].size(); ++i) {
    edge& e = graph_[v][i];
    if (e.cap > 0 && level[v] < level[e.to]) {
      T d = DFS(e.to, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        graph_[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

template<typename T>
T Dinic<T>::MaxFlow(const int& s, const int& t) {
  T flow = 0;
  for(;;){
    BFS(s);
    if (level[t] < 0) return flow;
    std::fill(iter.begin(), iter.end(), 0);
    T f;
    while ((f = DFS(s, t, std::numeric_limits<T>::max() / 2)) > 0) {
      flow += f;
    }
  }
}

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());

  int n; cin >> n;
  vector<int> a(n), b(n), c(n), d(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> c[i] >> d[i];
  }

  Dinic<int> dinic(2 * n + 2);
  int s = 2 * n, t = 2 * n + 1;

  // s → Red
  for (int i = 0; i < n; ++i) {
    dinic.AddEdge(s, i, 1);
  }

  // Blue → t
  for (int i = 0; i < n; ++i) {
    dinic.AddEdge(n + i, t, 1);
  }

  // Red → Blue
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (a[i] < c[j] && b[i] < d[j]) {
        dinic.AddEdge(i, j + n, 1);
      }
    }
  }

  cout << dinic.MaxFlow(s, t) << '\n';

  return 0;
}

Measured memory_bytes: 384