#include<stdio.h>
#include<math.h>
#include<string.h>
int main (){
int a[1002],d[1002];
int b,c,e,k,i,l,n,m,g,j,f;
scanf("%d",&g);
scanf("%d %d",&a[0],&d[0]);
for(i=1,k=0,l=0;i<g;i++){
scanf("%d %d",&a[i],&d[i]);
for(j=0,f=0;j<i;j++){
if(a[j]==0)
continue;
if((a[j]>=a[i]&&d[j]>=d[i])||(a[j]>=d[i]&&d[j]>=a[i]))
{a[j]=a[i],d[j]=d[i];
a[i]=0;d[i]=0;
f=1;break;}
}}
for(i=0,e=0;i<g;i++)
if(a[i]!=0)
e++;
printf("%d\n",e);
return 0;}