#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; bool bo[200020] = { false }; vector> vec; int main() { long long n, m; cin >> n >> m; for (int i = 0; i < n; i++) { int b, c; cin >> b >> c; vec.emplace_back(make_pair(c, b)); } sort(vec.begin(), vec.end()); int ans = 0; for (int i = 1; i < n; i++){ if (vec[i - 1].first == vec[i].first) { if (!bo[vec[i].second] && vec[i - 1].second != vec[i].second) { bo[vec[i].second] = true; ans++; } } } cout << ans << endl; }