#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > nums;
  pair<int, int> temp;
  while (n-- > 0) {
    cin >> temp.second >> temp.first;
    nums.push_back(temp);
  }
  sort(nums.begin(), nums.end());
  int count = 1;
  n = 1;
  int prev = nums[0].first;
  while (n < nums.size()) {
    if (nums[n].second > prev) {
      prev = nums[n].first;
      count++;
    }
    n++;
  }
  cout << count << endl;
}
