#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define ff first
#define ss second

const int N = 1e5 + 1;
const int b = 320;

struct haszownik{
    ll operator()(pii p) const noexcept{
        ll x = p.first, y = p.second;

        return (x << 32) | y;
    }
};


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    unordered_map<int, unordered_map<int, int>> wiersze;
    unordered_map<int, int> ile;
    unordered_map<pii, ll, haszownik> pary;
    vi ciezkie, lekkie;
    for(int i = 1; i <= n; i++){
        int x, y; cin >> x >> y;
        wiersze[x][y]++;
        ile[x]++;
    }

    for(auto& pk : ile){
        if(pk.ss >= b) ciezkie.pb(pk.ff);
        else lekkie.pb(pk.ff);
    }


    ll wyn = 0;

    int m = ciezkie.size();
    for(int i = 0; i < m; i++){
        for(int j = i + 1; j < m; j++){
            int x1 = ciezkie[i], x2 = ciezkie[j];
            if(ile[x1] > ile[x2]) swap(x1, x2);
            ll cnt = 0;
            for(auto& t : wiersze[x1]){
                int y = t.ff;
                if(wiersze[x2].find(y) != wiersze[x2].end()) cnt++;
            }
            wyn += (cnt - 1) * cnt / 2;
        }
    }
    int k = lekkie.size();
    for(int i = 0; i < m; i++){
        for(int j = 0; j < k; j++){
            int x1 = lekkie[j], x2 = ciezkie[i];
            ll cnt = 0;
            for(auto& t : wiersze[x1]){
                int y = t.ff;
                if(wiersze[x2].find(y) != wiersze[x2].end()) cnt++;
            }
            wyn += (cnt - 1) * cnt / 2;
        }
    }

    for(int i = 0; i < k; i++){
        int x = lekkie[i];
        vi elem;
        for(auto& t : wiersze[x]) elem.pb(t.ff);
        int z = elem.size();
        for(int j = 0; j < z; j++){
            for(int l = j + 1; l < z; l++){
                int y1 = elem[j], y2 = elem[l];
                if(y1 > y2) swap(y1, y2);
                wyn += pary[make_pair(y1, y2)];
                pary[make_pair(y1, y2)]++;
            }
        }
    }



    cout << wyn << "\n";





    return 0;
}

