#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
#ifdef home
    freopen("f.in", "r", stdin);
    freopen("f.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m, usls;
    cin >> n >> m >> usls;
    vector<unordered_set<int>> g(n);
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--, u--;
        g[v].emplace(u);
    }
    vector<bool> used(n);
    auto idfs = [&](auto &&self, int v) -> void {
        used[v] = true;
        for (auto &u: g[v]) {
            if (!used[u]) {
                self(self, u);
            }
        };
    };
    int cnt = 0;
    for (int v = 0; v < n; v++) {
        auto kek = g[v];
        for (auto &u: kek) {
            fill(used.begin(), used.end(), false);
            g[v].erase(u);
            idfs(idfs, v);
            bool good1 = true;
            for (auto el: used) {
                good1 &= el;
            }
            fill(used.begin(), used.end(), false);
            idfs(idfs, u);
            bool good2 = true;
            for (auto el: used) {
                good2 &= el;
            }
            if (!good1 || !good2) {
                cnt++;
            }
            g[v].emplace(u);
        }
    }
    cout << min(n - 1, cnt) << '\n';
    cout << "-1\n";
    return 0;
}
