#include <bits/stdc++.h>
using namespace std;
pair<long int, long int> p[500005];
bool cmp(pair<long int, long int> p1, pair<long int, long int> p2) {
  if (p1.second < p2.second)
    return true;
  else {
    if (p1.first < p2.first)
      return true;
    else
      return false;
  }
}
int main() {
  int n;
  int i, ans = 0, l;
  cin >> n;
  for (i = 0; i < n; i++) cin >> p[i].second >> p[i].first;
  sort(p, p + n);
  ans++;
  l = p[0].first;
  for (i = 1; i < n; i++) {
    if (p[i].second > l) {
      l = p[i].first;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
