// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #pragma GCC target("avx2")

using namespace std;
// using namespace __gnu_pbds;

// #define int long long
// #define ordered_set tree<int, null_type, less<int>, tree_order_statistics_node_update, rb_tree_tag>


void solve() {
    int n, m, g;
    cin >> n >> m >> g;
    vector<vector<int>> gr(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        cin >> a >> b;
        gr[a - 1].push_back(b - 1);
    }
    vector<bool> used(n);
    int ans = m - n;
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            used[i] = 1;
            ans++;
        }
        for (auto e : gr[i]) used[e] = 1;
    }
    cout << ans << '\n';
}

signed main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
}