#include "bits/stdc++.h"

using namespace std;
#define ll long long
#define ff first
#define ss second
mt19937 rnd(time(0));
#define int long long
const int mod = 1e9 + 7;
const int maxn = 2005;
vector<int> g[maxn];

void solve() {
    int n, m, g1;
    cin >> n >> m >> g1;
    int cnt = 0;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        if (a + 1 != b)cnt++;
        a--;
        b--;
        g[a].push_back(b);
    }
    cout << cnt;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}