// semenInRussia 2025
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define nl '\n'

const int N = 2005;
vector<int> g[N];

const int mod = 1e9 + 7;
bool used[N];

void dfs(int x) {
  used[x] = true;
  for (int y : g[x]) {
    if (!used[y]) {
      dfs(y);
    }
  }
}

int pow(int x, int k) {
  int ans = 1;
  while (k) {
    if (k & 1) {
      ans = 1ll * ans * x % mod;
    }
    x = 1ll * x * x % mod;
    k >>= 1;
  }
  return ans;
}

int main() {
  int n, m, tg;
  cin >> n >> m >> tg;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
  }

  int ans = m - n;

  for (int i = 0; i < n; i++) {
    if (!used[i]) {
      ans++;
      dfs(i);
    }
  }

  cout << ans << " -1";
}