#include <bits/stdc++.h>
using namespace std;
class activities {
 public:
  int starttime, endtime;
  bool operator<(const activities& b) const { return endtime < b.endtime; }
};
int main() {
  int n;
  cin >> n;
  vector<activities> a(n);
  for (int i = 0; i < n; i++) cin >> a[i].starttime >> a[i].endtime;
  sort(a.begin(), a.end());
  int ans = 1;
  activities last = a[0];
  for (int i = 1; i < n; i++) {
    if (a[i].starttime > last.endtime) {
      ans++;
      last = a[i];
    }
  }
  cout << ans << endl;
  return 0;
}
