题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2037
//C++代码
#include<iostream>
#include<algorithm>
using namespace std;
struct T{
int s,e;
bool operator <(const T a) const{
return e<a.e;
}
}t[100];
int main(){
int n,i;
while(cin>>n,n){
for(i=0;i<n;i++) cin>>t[i].s>>t[i].e;
sort(t,t+n);
int ans=1;
int min=t[0].e;
for(i=1;i<n;i++){
if(t[i].s>=min){
ans++;
min=t[i].e;
}
}
cout<<ans<<endl;
}
return 0;
}