#include using Pos = std::pair; int main () { int N; std::cin >> N; int x, y; std::vector positions, same_y; size_t cnt = 0; for (int i = 0; i < N; ++i) { std::cin >> x >> y; positions.push_back({x,y}); same_y.push_back({x,y}); } std::sort(positions.begin(), positions.end(), [] (const Pos & a, const Pos & b){ if (a.first == b.first) return a.second < b.second; return a.first < b.first; }); std::sort(same_y.begin(), same_y.end(), [] (const Pos & a, const Pos & b){ if (a.second == b.second) return a.first < b.first; return a.second < b.second; }); for (size_t i = 0; i + 1 < positions.size(); ++i) { if (positions[i].first == positions[i+1].first) cnt++; if (same_y[i].second == same_y[i+1].second) cnt++; } std::cout << positions.size() - cnt - 1 << std::endl; return 0; }