#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int co[200020] = {}; int main() { long long n, m; cin >> n >> m; for (int i = 0; i < n; i++) { int b, c; cin >> b >> c; co[c]++; } int ans = 0; for (int i = 1; i <= n; i++) { if (co[i] != 0) { ans += co[i] - 1; } } cout << ans << endl; }