#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<long long int, long long int> > vect;
  long long int l, r;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    vect.push_back(make_pair(r, l));
  }
  sort(vect.begin(), vect.end());
  int ans = 1;
  long long int end = vect[0].first;
  for (int i = 1; i < n; i++) {
    if (vect[i].second > end) {
      ans++;
      end = vect[i].first;
    }
  }
  cout << ans << "\n";
  return 0;
}
