#include <iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int row[n],col[n];
    for(int i=0,i<n;i++)
    {
        int r,c;
        cin>>r>>c;
        row[r-1]++;
        col[c-1]++;
    }
    int broj=0;
    for(int i=0;i<n;i++)
    {
        if(!row[i]) broj++;
        if(!col[i]) broj++;
    }
    cout<<broj;
    return 0;
}