#include <bits/stdc++.h>
using namespace std;

void dfs(vector<vector<int>>& g, int x, int y, int z, vector<bool>& used) {
    if (used[x]) {
        return;
    }
    used[x] = true;
    for (auto i : g[x]) {
        if ((x != y) || (i != z)) {
            dfs(g, i, y, z, used);
        }
    }
}

int main() {
    int n, m, G, q, r;
    cin >> n >> m >> G;
    if ((G < 3) || (G > 4)) {
        return 0;
    }
    vector<vector<int>> g(n, vector<int>(0));
    for (int i = 0; i < m; i++) {
        cin >> q >> r;
        q--;
        r--;
        g[q].push_back(r);
    }
    vector<vector<bool>> is_bridge(n);
    vector<vector<bool>> is_connected(n, vector<bool>(n, true));
    vector<bool> used;
    for (int i = 0; i < n; i++) {
        is_bridge[i].assign(g[i].size(), false);
        for (int j = 0; j < g[i].size(); j++) {
            used.assign(n, false);
            dfs(g, i, i, g[i][j], used);
            if (!used[g[i][j]]) {
                is_bridge[i][j] = true;
            }
        }
        used.assign(n, false);
        dfs(g, i, -1, -1, used);
        for (int j = 0; j < n; j++) {
            if (!used[j]) {
                is_connected[i][j] = false;
                is_connected[j][i] = false;
            }
        }
    }
    vector<int> sccs(n, -1);
    for (int i = 0; i < n; i++) {
        if (sccs[i] == -1) {
            for (int j = 0; j < n; j++) {
                if (is_connected[i][j]) {
                    sccs[j] = i;
                }
            }
        }
    }
    int not_bridges(0);
    vector<vector<int>> g1(n, vector<int>(0));
    vector<vector<int>> g2(n, vector<int>(0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < g[i].size(); j++) {
            if ((!is_bridge[i][j]) && (sccs[i] != sccs[g[i][j]])) {
                not_bridges++;
            } else if ((is_bridge[i][j]) && (sccs[i] == sccs[g[i][j]])) {
                g2[i].push_back(g[i][j]);
            } else if ((!is_bridge[i][j]) && (sccs[i] == sccs[g[i][j]])) {
                g1[i].push_back(g[i][j]);
            }
        }
    }
    vector<vector<bool>> is_connected_2(n, vector<bool>(n, true));
    for (int i = 0; i < n; i++) {
        used.assign(n, false);
        dfs(g1, i, -1, -1, used);
        for (int j = 0; j < n; j++) {
            if (!used[j]) {
                is_connected_2[i][j] = false;
                is_connected_2[j][i] = false;
            }
        }
    }
    /*vector<int> sccs2(n, -1);
    for (int i = 0; i < n; i++) {
        if (sccs2[i] == -1) {
            for (int j = 0; j < n; j++) {
                if (is_connected_2[i][j]) {
                    sccs2[j] = i;
                }
            }
        }
    }
    vector<vector<int>> g3(n, vector<int>(0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < g2[i].size(); j++) {
            g3[sccs2[i]].push_back(sccs2[g2[i][j]]);
        }
    }*/
    cout << not_bridges << endl;
    cout << 1 << endl;
}
