#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  set<pair<int, int> > clientes;
  for (int i = (0); i < (n); i++) {
    int l, r;
    cin >> l >> r;
    clientes.insert(make_pair(r, l));
  }
  int ans = 0;
  int last = 0;
  for (auto it = clientes.begin(); it != clientes.end(); it++) {
    if (it->second > last) {
      ans++;
      last = it->first;
    }
  }
  cout << ans << endl;
  return 0;
}
