#include
#include
using namespace std;
struct Ti{
int s;
int e;
bool operator < (const Ti& other) const
{
if(this->e==other.e)
this->s
return this->e
}
};
int main()
{
//freopen("in.txt", "r", stdin);
int n,s,e,ans=1,d=1;
Ti t1[101],t2[101];
while(~scanf("%d",&n)&&n)
{
ans=1;
d=1;
for(int i=0;i
{
scanf("%d%d",&s,&e);
t1[i].s=s;
t1[i].e=e;
}
stable_sort(&t1[0],&t1[n]);//按照节目时间由短到长排列
t2[0]=t1[0];//因为第一个是必须看的;
//cout<<"t1[0].s="<<t1[0].s<<" "<<"t1[0].e="<<t1[0].e<<endl;
for(int i=1;i
{
if(t1[i].s>=t2[d-1].e)
{
//cout<<"t2[d-1].s="<<t2[d-1].s<<" "<<"t2[d-1].e="<<t2[d-1].e<<endl;
t2[d++]=t1[i];
ans++;
}