//简单....
1 #include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define maxn 105
struct t
{
int s;
int e;
};
t T[maxn];
int cmp(const void *_p,const void *_q)
{
t *p = (t *)_p;
t *q = (t *)_q;
return p->e - q->e;
}
int n;
int main()
{
int res;
int cur;
while(scanf("%d",&n) && n)
{
for(int i = ; i < n; i++)
scanf("%d%d",&T[i].s,&T[i].e);
qsort(T,n,sizeof T[],cmp);
cur = T[].e;
res = ;
for(int i = ; i < n; i++)
{
if(T[i].s >= cur)
{
cur = T[i].e;
res++;
}
}
printf("%d\n",res);
}
return ;
}