#include #include #include #include #include int main() { int n, m; std::vector< std::pair > A; std::cin >> n >> m; A.reserve(n); for (int i = 0; i < n; i++) { int b, c; std::cin >> b >> c; A.emplace_back(b, c); } std::sort(A.begin(), A.end(), [](std::pair& a, std::pair& b) { return a.second == b.second ? a.first < b.first : a.second < b.second; }); std::set> C; for (int i = 0; i < n - 1; i++) { if (A[i].second == A[i+1].second && A[i].first != A[i+1].first) { C.emplace(A[i].first, A[i+1].first); } } std::cout << C.size() << std::endl; return 0; }