#include <bits/stdc++.h>
using namespace std;
long long int dp[500100], n;
vector<pair<long long int, long long int> > vec;
long long int solve(long long int n) {
  long long int x, ans = 1;
  x = vec[0].first;
  for (long long int i = 1; i < n; i++) {
    if (vec[i].second > x) {
      ans += 1;
      x = vec[i].first;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  long long int l, r;
  memset(dp, -1, sizeof(dp));
  for (long long int i = 0; i < n; i++) {
    cin >> l >> r;
    vec.push_back({r, l});
  }
  sort(vec.begin(), vec.end());
  cout << solve(n) << endl;
  return 0;
}
