//#include //using namespace atcoder; #include using namespace std; typedef long long ll; #define REP(i, n) for(int i=0; i=0; i--) #define FOR(i, m, n) for(int i=m; i> using P = pair; using LP = pair; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int INF = 1e9; const ll LINF = (1LL<<60); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n,m; cin >> n >> m; vector> st(n); REP(i,n){ int b,c; cin >> b >> c; c--; st[c].insert(b); } int ans = 0; REP(i,n){ if(!st[i].empty()) ans += st[i].size()-1; } cout << ans << endl; return 0; }