#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
using namespace std;
const int SZ = 2282280;
signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  vector<bool> was(n, false);
  for (auto &i : p) cin >> i;
  for (int i = 0; i < n; ++i) p[i]--;
  vector<int> cnt(n + 1, 0);
  int c1 = 0, c2 = 0;
  bitset<SZ> b;
  for (int i = 0; i < n; ++i) {
    if (was[i]) continue;
    int x = i, len = 0;
    while (!was[x]) {
      was[x] = true;
      x = p[x];
      ++len;
    }
    c1 += len % 2;
    c2 += len / 2;
    cnt[len]++;
  }
  b.set(n);
  for (int i = 1; i <= n; ++i) {
    if (cnt[i] == 0) continue;
    int j = 1;
    while (cnt[i] > 0) {
      j = min(j, cnt[i]);
      int u = i * j;
      b |= (b >> u);
      cnt[i] -= j;
      j *= 2;
    }
  }
  int ans = k;
  if (!b.test(n - k)) ++ans;
  int mx = 0;
  mx += 2 * min(k, c2);
  k -= min(k, c2);
  mx += min(k, c1);
  cout << ans << " " << mx << endl;
  return 0;
}
