#include #include #include using namespace std; typedef struct HEAD { long x; long y; } HEAD; int main() { long N; cin >> N; int count = 0; HEAD heads[N]; bool good = false; for (int i = 0; i < N; i++) { cin >> heads[i].x; cin >> heads[i].y; } HEAD stop[N]; for (int i = 0; i < N; i++) { good = false; for (int j = 0; j < N; j++) { if (i != j && (stop[i].x != heads[i].x || stop[i].y != heads[i].y) && (heads[i].x == heads[j].x || heads[i].y == heads[j].y)) { good = true; stop[i].x = heads[i].x; stop[i].y = heads[i].y; } } if(!good) count++; } /*for (int i = 0; i < N; i++) { change = false; if (i > 0 && (heads[i].x != heads[i - 1].x && heads[i].y != heads[i - 1].y)) { change = true; } if(change) count++; }*/ cout << count << "\n"; return 0; }