#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin>>n;

    int poolX[n]={0};
    int poolY[n]={0};

    pair <int,int> niz[n];

    for(int i=0;i<n;i++)
    {
        cin>>niz[i].first>>niz[i].second;

        poolX[niz[i].first]++;
        poolY[niz[i].second]++;

    }
    if(n==2)
    {
        if(niz[0].first==niz[1].first || niz[0].second==niz[1].second)
            cout<<1;
        else
            cout<<0;
    }
    else
    {
     int resenje=0;

    for(int i=0;i<n;i++)
    {
        if(poolX[i]!=0)
            resenje=resenje+poolX[i]-1;
        if(poolY[i]!=0)
            resenje=resenje+poolY[i]-1;

    }

        cout<<resenje;
    }



    return 0;
}