#include<bits/stdc++.h>
//#pragma GCC target("avx2")
//#define int long long
#define F first
#define S second

using namespace std;

const int N = 3000+10;

vector<int> g[N], g_ob[N];

bool us[N+10]; int cnt = 0;

int fl[N][N];

void dfs(int v)
{
    us[v] = 1;
    cnt++;
//    cout<<"--->"<<v<<endl;
    for(auto i:g[v])
    {
        if(us[i] || fl[v][i] == 2) continue;
        dfs(i);
    }
    for(auto i:g_ob[v])
    {
        if(us[i] || !fl[v][i]) continue;
        dfs(i);
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int n, m, g1;
    cin>>n>>m>>g1;
    vector<pair<int, int>> v;
    for(int i = 1; i <= m; i++)
    {
        int x, y;
        cin>>x>>y;
        g[x].push_back(y);
        g_ob[y].push_back(x);
        v.push_back({x, y});
    }
    int ans = 0;
    for(auto i:v)
    {
        fl[i.F][i.S] = 2;
        fl[i.S][i.F] = 2;
        int o = 0;
        cnt = 0;
        fill(us, us+n+10, 0);
        dfs(i.F);
        if(cnt != n)
            o = 1;
        cnt = 0;
        fill(us, us+n+10, 0);
        dfs(i.S);
        if(cnt != n)
            o = 1;
        if(o)
        {
            fl[i.F][i.S] = 1;
            fl[i.S][i.F] = 1;
            ans++;
        }
        else
        {
            fl[i.F][i.S] = 0;
            fl[i.S][i.F] = 0;
        }
//        break;
    }
    cout<<ans<<"\n1";

}

