#include <bits/stdc++.h>

using namespace std;


int main(){
    // x_a < x_b
    // y_a < y_b
    
    int n; cin >> n;
    vector<pair<long long, long long>> points(n);
    for (int i = 0; i < n; i++) {
        cin >> points[i].first >> points[i].second;
    }

    long long count = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            auto [x_a, y_a] = points[i];
            auto [x_b, y_b] = points[j];
            if (x_a < x_b && y_a < y_b || x_b < x_a && y_b < y_a) { // either A dominates B or B domites A
                count++;
            }
        }
    }
    cout << count << endl;

    return 0;
}