#include <bits/stdc++.h>

using namespace std;

#define MAX_N 114
#define MAX_V 514

int V;
vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v] = true;
  for(int i = 0 ; i < (int)G[v].size() ; i++){
    int u = G[v][i],w = match[u];
    if(w < 0 || !used[w] && dfs(w)){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res = 0;
  memset(match,-1,sizeof(match));
  for(int v = 0 ; v < V ; v++){
    if(match[v] < 0){
      memset(used,false,sizeof(used));
      if(dfs(v)){ res++; }
    }
  }
  return res;
}

int main(){
  int N,h[MAX_N],w[MAX_N];
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> w[i] >> h[i];
  }
  V = N*2;
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      if(i == j){ continue; }
      if((h[i] < h[j] && w[i] < w[j]) || (h[i] < w[j] && w[i] < h[j])){
        add_edge(i,j+N);
      }
    }
  }
  cout << N-bipartite_matching() << endl;
  return 0;
}
