#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll

vector<set<int>> g;
vector<set<int>> rg;
vector<vector<int>> cg;
int n, m, T;

void ts_dfs(int v, vector<int> &used, vector<int> &ts, vector<set<int>> &g) {
    used[v] = 1;
    for (auto u : g[v]) {
        if (!used[u]) {
            ts_dfs(u, used, ts, g);
        }
    }
    ts.push_back(v);
}

vector<int> tsort(vector<set<int>> &g) {
    vector<int> res; 
    vector<int> used(n + 1);
    for (int i = 1; i <= n; i++) {
        if (!used[i]) {
            ts_dfs(i, used, res, g);
        }
    }
    reverse(res.begin(), res.end());
    return res;
}

vector<int> color;
int tc = 1;
int ud = 0, cnt = 0;

void f_kss(int v, vector<set<int>> &g) {
    color[v] = tc;
    for (auto u : g[v]) {
        if (!color[u]) {
            f_kss(u, g);
        }
    }
}

bool flag = false;

void dfs(int v, vector<int> &used) {
    used[v] = 1;
    for (auto u : cg[v]) {
        if (used[u] == 0)
            dfs(u, used);
        if (used[u] == 1)
            flag = 1;
    }
    used[v] = 2;
}



bool cyc() {
    flag = 0;
    vector<int> used(tc + 1);
    for (int i = 1; i <= tc; i++) {
        if (!used[i])
            dfs(i, used);
    }
    return flag;
}

void solve() {
    cin >> n >> m >> T;
    g.resize(n + 1);
    rg.resize(n + 1);
    cg.resize(n + 1);
    color.resize(n + 1);
    cnt = 1;
    vector<pair<int, int>> edges(m);
    for (int i = 0, a, b; i < m; i++) {
        cin >> a >> b;
        edges[i] = {a, b};
        g[a].emplace(b);
        rg[b].emplace(a);
    }
    auto ts = tsort(g);
    for (auto v : ts) {
        if (!color[v]) {
            f_kss(v, rg);
            tc++;
        }
    }
    for (int i = 0; i < m; i++) {
        auto [a, b] = edges[i];
        if (color[a] == color[b])
            continue;
        cg[color[a]].push_back(color[b]);
    }
    for (int i = 0; i < m; i++) {
        auto [a, b] = edges[i];
        if (color[a] == color[b]) {
            
        }
        else {
            a = color[a];
            b = color[b];
            cg[a].erase(find(cg[a].begin(), cg[a].end(), b));
            cg[b].emplace_back(a);
            if (cyc()) {
                ud++;
                cerr << a << " " << b << "\n";
            }
            cg[b].erase(find(cg[b].begin(), cg[b].end(), a));
            cg[a].emplace_back(b);
        }
    }
    cout << ud << "\n" << cnt;
}

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