#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n;
  cin >> n;
  vector<pair<int, int>> vp(n);
  for (int i = 0; i < n; i++) cin >> vp[i].first >> vp[i].second;
  sort(vp.begin(), vp.end());
  long long res = 1;
  pair<int, int> pa = {vp[0].first, vp[0].second};
  for (int i = 0; i < n; i++) {
    if (vp[i].first > pa.second)
      pa = {vp[i].first, vp[i].second}, res++;
    else if (vp[i].second < pa.second)
      pa = {vp[i].first, vp[i].second};
  }
  cout << res << endl;
  return 0;
}
