#include <bits/stdc++.h>

using namespace std;
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;

void solve();

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int tt = 1; //cin >> tt;
    while (tt--) {
        solve();
        cout << "\n";
    }
}

const int N = 2001;

vector<int> g[N];
int used[N], ans = 0;

void dfs(int v) {
    used[v] = 1;
    for (auto u : g[v]) {
        if (used[u]) ans++;
        else dfs(u);
    }
}

void solve() {
    int n, m, q; cin >> n >> m >> q;
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b; a--, b--;
        g[a].push_back(b);
    }
    dfs(0);
    cout << ans << "\n1";
}



