#define _CRT_SECURE_NO_WARNINGS


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>


using namespace std;
using ll=long long;
const ll inf = 1e6;

vector<vector<ll>>g(2001);
ll tr = 0;
ll used[2001][2001];
void dfs(int x) {
	used[tr][x] = 1;
	for (int i = 0; i < g[x].size(); ++i) {
		if (used[tr][g[x][i]] == 0) {
			used[tr][g[x][i]] = 1;
			dfs(g[x][i]);
		}
		else {
			used[tr][g[x][i]]++;
		}
	}
}
int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n, m, t;
	cin >> n >> m >> t;
	vector<pair<ll, ll>> edges;
	int fl = 0;
	for (int i = 1; i <= m; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		edges.push_back({ u,v });
	}
	for (int i = 1; i <= n; ++i) {
		++tr;
		dfs(i);
	}
	for (int i = 0; i < edges.size(); ++i) {
		if (edges[i].second != edges[i].first + 1 && used[edges[i].first][edges[i].second] >1) {
			++fl;
		}
	}
	cout << fl << "\n" << 1;

}