#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
bool cmp(pair<int, int> a, pair<int, int> b) { return a.second < b.second; }
int main() {
  int n, l, r, ri = 0;
  cin >> n;
  vector<pair<int, int> > tm;
  for (long long i = 0; i < n; i++) {
    cin >> l >> r;
    tm.push_back(make_pair(l, r));
  }
  sort(tm.begin(), tm.end(), cmp);
  int cont = 1;
  ri = tm[0].second;
  cout << endl;
  for (long long i = 1; i < tm.size(); i++) {
    if (tm[i].first <= ri)
      continue;
    else {
      ri = tm[i].second;
      cont++;
    }
  }
  cout << cont << endl;
}
