#include <bits/stdc++.h>
using namespace std;
int n;
const int N = (int)5e5 + 10;
vector<pair<int, int>> a;
int main() {
  scanf("%d", &n);
  a = vector<pair<int, int>>(n);
  for (int i = 0; i < n; i++) scanf("%d%d", &a[i].second, &a[i].first);
  sort(a.begin(), a.end());
  int i = 0;
  int ans = 1;
  for (int j = 1; j < n; j++) {
    if (a[j].second > a[i].first) {
      ans++;
      i = j;
    }
  }
  printf("%d\n", ans);
}
