#include<bits/stdc++.h>

using namespace std;
int main(){
	long long N,temp,temp1,rez=0;
	vector<long long>r;
	vector<long long>k;
	vector<long long>red;
	vector<long long>kol;
	cin>>N;
	for(long long i=0;i<N;i++){
		cin>>temp>>temp1;
		r.push_back(temp);
		k.push_back(temp1);
		red.push_back(0);
		kol.push_back(0);
	}
	for(long long i=0;i<N;i++){
		if(red[r[i]-1]==0){
			red[r[i]-1]=1;
			rez++;
		}
		if(kol[k[i]-1]==0){
			kol[k[i]-1]=1;
			rez++;
		}
	}
	cout<<2*N-rez;
	return 1;
}