#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
inline void solve() {
  long long n;
  cin >> n;
  vector<pair<long long, long long> > v(n);
  for (long long i = 0; i < n; i++) cin >> v[i].second >> v[i].first;
  sort(v.begin(), v.end());
  long long ans = 0, pre = 0;
  for (long long i = 0; i < n; i++) {
    if (v[i].second > pre) {
      ans++;
      pre = v[i].first;
    }
  }
  cout << ans << '\n';
}
signed main() {
  long long n = 1;
  while (n--) solve();
  return 0;
}
