#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7;
#define all(a) a.begin(), a.end()
#define rall(a) a.begin(), a.end()
vector<vector<int>> g;
vector<int> used;
int u1, u2;

void dfs(int v) {
    used[v] = 1;
    for (auto to: g[v]) {
        if (v == u1 && to == u2) {
            continue;
        }
        if (!used[to]) {
            dfs(to);
        }
    }
}

void solve() {
    int n, m, gr;
    cin >> n >> m >> gr;
    g.resize(n);
    vector<pair<int, int>> edge;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        g[u - 1].push_back(v - 1);
        edge.emplace_back(u - 1, v - 1);
    }
    int cnt = 0;
    for (auto [u, v]: edge) {
        u1 = u, u2 = v;
        used.assign(n, 0);
        dfs(u);
        for (int i = 0; i < n; ++i) {
            if (!used[i]) {
                cnt++;
                break;
            }
        }
    }
    cout << cnt << "\n1\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
