#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  cin >> n;
  vector<pair<int, int>> vec;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    vec.push_back(make_pair(b, a));
  }
  sort(vec.begin(), vec.end());
  int ans = 0, sofar = 0;
  for (int i = 0; i < n; i++)
    if (vec[i].second > sofar) {
      sofar = vec[i].first;
      ans++;
    }
  cout << ans << endl;
  return 0;
}
