#include <bits/stdc++.h>
using namespace std;
int N, ans;
pair<int, int> meeting[100000];
int main() {
  std::ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> meeting[i].second >> meeting[i].first;
  sort(meeting, meeting + N);
  ans = N;
  int cur = meeting[0].first;
  for (int i = 1; i < N; i++) {
    if (meeting[i].second < cur)
      ans--;
    else
      cur = meeting[i].first;
  }
  cout << ans;
  return 0;
}
