#include <iostream>
//#include <algorithm>
//#include <cmath>
//#include <string>
using namespace std;

int main(){

    int n,red,kolona,i,s,br=0; cin >> n;
    int r[n+1];
    int k[n+1];
    for(i=1;i<=n;i++){
        r[i]=0;
        k[i]=0;
    }
    for(i=0;i<n;i++){
        cin >> red >> kolona;
        r[red]++;
        k[kolona]++;
    }
    for(i=1;i<=n;i++){
        if(r[i]==0){br++;}
        if(k[i]==0){br++;}
    }
    cout << br;


    return 0;
}