/** * author: shu8Cream * created: 12.02.2021 21:19:22 **/ #include using namespace std; #define rep(i,n) for (int i=0; i<(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; using P = pair; using vi = vector; using vvi = vector; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n,m; cin >> n >> m; vi b(n),c(n),slime(n),bara; rep(i,n){ cin >> b[i] >> c[i]; slime[c[i]]++; } rep(i,n) if(slime[i]>1) bara.push_back(i); //rep(i,bara.size()) cout << bara[i] << endl; int ans = 0; rep(i,bara.size()){ set s; rep(j,n){ if(c[j]==bara[i]) s.insert(b[j]); } ans+=s.size()-1; } cout << ans << endl; }