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