#include<bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,sse3,sse4,bmi,bmi2,popcnt,lzcnt,tune=native")
using namespace std;
vector<int>g[2001];
bool was[2001];
int anss[2001];
vector<int>ans;
void dfs(int v) {
    was[v] = 1;
    for (auto u : g[v]) {
        if (!was[u]) {
            dfs(u);
        }
    }
    ans.push_back(v);
}
int sz = 0;
void dfss(int v) {
    anss[v] = sz;
    for (auto u : g[v]) {
        if (!anss[u]) {
            dfss(u);
        }
    }
}
int n, m, G;
vector<int> css() {
    ans.clear();
    fill(was + 1, was + n + 1, 0);
    for (int i = 1; i <= n; i++) {
        if (!was[i]) {
            dfs(i);
        }
    }
    sz = 1;
    for (auto u : ans) {
        if (!anss[u]) {
            dfss(u);
        }
    }
    vector<int>o;
    for (int i = 1; i <= n; i++) {
        o.push_back(anss[i]);
        anss[i] = 0;
    }
    return o;
}
main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> G;
    // cout << fixed << pow(3, 14) << endl;
    int u[m], v[m];
    for (int i = 0; i < m; i++) {
        cin >> u[i] >> v[i];
    }
    int cnt = 0;
    vector<int>org = css();
    for (int i = 0; i < m; i++) {
        for (int i = 1; i <= n; i++) {
            g[i].clear();
        }
        for (int j = 0; j < m; j++) {
            if (i != j) {
                g[u[j]].push_back(v[j]);
            } else {
                g[v[j]].push_back(u[j]);
            }
        }
        if (css() != org) {
            cnt++;
        }
    }
    cout << cnt << endl;
    cout << -1 << endl;
}
/*
A:12
B:100
C:52
D:4

168
*/