#include <bits/stdc++.h>
using namespace std;
int n, k, p[1000005], num, cnt, tot, b[1000005], ans1, ans2, d[1000005],
    e[1000005], a[1000005];
bool vis[1000005], dp[1000005];
int min(int a, int b) { return (a < b ? a : b); }
int main() {
  scanf("%d%d", &n, &k);
  ans2 = k;
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    cnt = 0;
    int j = i;
    while (!vis[j]) {
      vis[j] = 1;
      cnt++;
      j = p[j];
    }
    b[++num] = cnt;
  }
  sort(b + 1, b + num + 1);
  int kk = k;
  for (int i = 1; i <= num; i++) {
    if (b[i] / 2 <= kk)
      ans1 += b[i] / 2 * 2, kk -= b[i] / 2;
    else
      ans1 += 2 * kk, kk = 0;
    if (b[i] & 1) tot++;
  }
  ans1 += min(kk, tot);
  tot = cnt = 0;
  for (int i = 1; i <= num; i++) {
    if (b[i] == b[i - 1])
      d[tot]++;
    else {
      d[++tot] = 1;
      e[tot] = b[i];
    }
  }
  for (int i = 1; i <= tot; i++)
    for (int j = 1; d[i]; j <<= 1) {
      int t = min(d[i], j);
      a[++cnt] = e[i] * t;
      d[i] -= t;
    }
  dp[0] = 1;
  for (int i = 1; i <= cnt; i++)
    for (int j = k - a[i]; j >= 0; j--)
      if (dp[j]) dp[j + a[i]] = 1;
  if (!dp[k]) ans2++;
  printf("%d %d\n", ans2, ans1);
  return 0;
}
