#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > v;
  while (n--) {
    int x, y;
    cin >> x >> y;
    v.push_back(make_pair(y, x));
  }
  int ans = 0, c = 0;
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    if (v[i].second > c) {
      ans++;
      c = v[i].first;
    }
  }
  cout << ans;
}
