#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n, j, k, br = 0;
    cin >> n;
    bool p[n + 1], d[n + 1];
    for(long long i = 1 ; i <= n ; i++){
        p[i] = false;
        d[i] = false;
    }
    for(long long i = 0 ; i < n ; i++){
        cin >> k >> j;
        if(p[k] == true) br++;
        else p[k] = true;
        if(d[j] == true) br++;
        else d[j] = true;
    }
    cout << br;
    return 0;
}