#include <iostream>

using namespace std;

int n;
//c1
int x1, y1, x2, y2;
//full
int nizx[200005], nizy[200005], up;
struct kordinate{
	int x, y, u;
};
kordinate k[200005];

int main(){
	cin >> n;
	//c1
	if(n == 1){
		cin >> x1 >> y1;
		cout << "0\n";
		return 0;
	}
	//c2
	else if(n == 2){
		cin >> x1 >> y1 >> x2 >> y2;
		if(x1 != x2 && y1 != y2){
			cout << "0\n";
			return 0;
		}
		else{
			cout << "1\n";
			return 0;
		}
	}
	else{
		for(int i = 1; i <= n; i++){
			cin >> k[i].x >> k[i].y;
			nizx[k[i].x]++;
			nizy[k[i].y]++;
		}
		for(int i = 1; i <= n; i++){
			if(nizx[i] > 1){
				up += nizx[i]-1;
				for(int z = 1; z <= n; z++) if(k[z].x == i) k[z].u++;
			}
			if(nizy[i] > 1) {
				up += nizy[i]-1; 
				for(int z = 1; z <= n; z++) if(k[z].y == i) k[z].u++;
			}
		}
		for(int i = 1; i <= n; i++){
			if(k[i].u == 2) up--;
		}
		cout << up << endl;
		return 0;
	}
	//nula
		for(int i = 1; i <= n; i++) cin >> x1 >> x1;
		cout << "0\n";
		return 0;
	1
}