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