#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=105;
const int inf=0x3f3f3f3f;
struct node
{
int x,y;
}p[maxn];
bool cmp(const node &a,const node &b)
{
if(a.y==b.y) return a.x>b.x;
return a.y<b.y;
}
int main()
{
int n;
while(~scanf("%d",&n))
{
if(n==0) break;
for(int i=1;i<=n;i++)
{
scanf("%d %d",&p[i].x,&p[i].y);
}
sort(p+1,p+1+n,cmp);
int ans=1,q=p[1].y;
for(int i=2;i<=n;i++)
{
if(p[i].y==p[i-1].y) continue;
if(p[i].x<q) continue;
ans++;
q=p[i].y;
}
printf("%d\n",ans);
}
}