#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;

int max_act(vector<PII>& acts) {
    int n = 1;
    int pre = acts[0].second;
    for (int i = 1; i < acts.size(); i++) {
        if (acts[i].first >= pre ) {
            n++;
            pre = acts[i].second;
        }
        else if(acts[i].second<=pre) {
            pre = acts[i].second;
        }
    }
    return n;
}
int main() {
    int n;
    cin >> n;
    vector<PII> acts(n);
    for (int i = 0; i < n; i++) {
        cin >> acts[i].first >> acts[i].second;
    }
    sort(acts.begin(), acts.end());

    cout << max_act(acts);
    return 0;
}