#include<stdio.h>
int main(){
int n,i,j,num=1;
int h[1000],w[1000];
scanf("%d",&n);
for(i=0;i<n;++i){
scanf("%d %d",&h[i],&w[i]);
}
for(i=1;i<n;++i){
for(j=0;j<i;j++){
if(((h[i]<=h[j])&&(w[i]<=w[j]))||((h[i]<=w[j])&&(w[i]<=h[j])))
break;
}
if(j!=i){
h[j]=h[i];
w[j]=w[i];
h[i]=0;
w[i]=0;
}
if(j==i)
num++;
}
printf("%d\n",num);
}