#include<bits/stdc++.h>
using namespace std;
int n;
struct part{
int a , b;
}x[20000000];
part tmp;
long long ans = 1;
bool cmp(part x , part y){
if(x.b == y.b) return x.a < y.a;
else return x.b < y.b;
}
void search(int t){
if(t == n){
ans++;
return;
} else {
for(int i = t + 1; i <= n; i++){
if(x[i].a >= tmp.b){
ans++;
tmp.a = x[i].a;
tmp.b = x[i].b;
search(i);
return;
}
}
}
}
int main(){
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> x[i].a >> x[i].b;
}
stable_sort(x + 1 , x + n + 1 , cmp);
tmp.a = x[1].a;
tmp.b = x[1].b;
search(1);
cout << ans;
return 0;
}