#include <iostream>
#include <cstring>
#include <algorithm>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
const int N = 100010;
PII w[N];
int n;
int main(){
cin >> n;
for(int i = 0; i < n; i++) cin >> w[i].y >> w[i].x;
sort(w, w + n);
int cnt = 0, last = -0x3f3f3f3f;
for(int i = 0; i < n; i++)
if(w[i].y > last){
cnt ++;
last = w[i].x;
}
cout << cnt << endl;
return 0;
}