#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<vector<int>> g(n);
    vector<vector<pair<int, int>>> cg(n);
    for (int i = 0; i < m; i++) {
        int v, u;
        cin >> v >> u;
        v--, u--;
        g[v].emplace_back(u);
        cg[v].emplace_back(u, i);
        cg[u].emplace_back(v, i);
    }
    vector<bool> used(n);
    vector<int> h(n), up(n);
    vector<bool> bridge(m, false);
    auto dfs = [&](auto &&self, int v, int par) -> void {
        used[v] = true;
        up[v] = h[v];
        for (auto &[u, i]: cg[v]) {
            if (u == par) {
                continue;
            }
            if (used[u]) {
                up[v] = min(up[v], h[u]);
            } else {
                h[u] = h[v] + 1;
                self(self, u, v);
                up[v] = min(up[v], up[u]);
                if (up[u] == h[u]) {
                    bridge[i] = true;
                }
            }
        }
    };
    for (int v = 0; v < n; v++) {
        if (!used[v]) {
            dfs(dfs, v, -1);
        }
    }
    fill(used.begin(), used.end(), false);
    vector<int> color(n);
    int free = 0;
    auto cdfs = [&](auto &&self, int v, int par) -> void {
        used[v] = true;
        color[v] = free;
        for (auto &[u, i]: cg[v]) {
            if (u == par || bridge[i]) {
                continue;
            }
            if (!used[u]) {
                self(self, u, v);
            }
        }
    };
    for (int v = 0; v < n; v++) {
        if (!used[v]) {
            cdfs(cdfs, v, -1);
            free++;
        }
    }
    int cnt = m;
    vector<int> flex(n);
    for (int v = 0; v < n; v++) {
        flex[color[v]]++;
    }
    for (int v = 0; v < n; v++) {
        for (auto &u: g[v]) {
            if (color[v] != color[u]) {
                cnt--;
            }
        }
    }
    for (int c = 0; c < n; c++) {
        cnt -= max(0, flex[c] - 1);
    }
    cout << cnt << '\n';
    cout << "-1\n";
    return 0;
}
