#include <bits/stdc++.h>

using namespace std;

int main(){
    int n; cin >> n;

    vector<pair<int, int>> intervals(n);
    for (int i = 0; i < n; i++) {
        cin >> intervals[i].first;
        cin >> intervals[i].second;
    }

    int count = 0;
    for (int i = 0; i < n; i++) {
        bool isInsideAnotherInterval = false;
        for (int j = 0; j < n; j++) {
            if (i == j) continue;

            if (intervals[j].first <= intervals[i].first && intervals[j].second >= intervals[i].second) {
                if (intervals[j].first == intervals[i].first && intervals[j].second == intervals[i].second) {
                    if (j < i) {
                        isInsideAnotherInterval = true;
                        break;
                    }
                } else {
                    isInsideAnotherInterval = true;
                    break;
                }
            }
        }
        if (!isInsideAnotherInterval) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}