#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;

    bool rows[n+1],cols[n+1];

    memset(rows, false, sizeof rows);
    memset(cols, false, sizeof cols);

    int a, b, rez = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a >> b;

        if(rows[a] || cols[b])
        {
            rez++;
        }

        rows[a] = true;
        cols[b] = true;
    }

    cout << rez;
}