#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
  int n;
  cin >> n;
  pair<int, int> a[n];
  for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  sort(a, a + n, comp);
  int last = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].first > last) ans++, last = a[i].second;
  }
  cout << ans << endl;
}
