#include <bits/stdc++.h>
using namespace std;
int cnt[1000005];
int n, m;
int p[1000005];
bool bz[1000005];
int ans1, ans2;
bitset<1000005> b;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (int i = 1; i <= n; i++) {
    if (bz[i]) continue;
    bz[i] = 1;
    int now = p[i];
    int tot = 1;
    while (1) {
      if (now == i) break;
      bz[now] = 1;
      ++tot;
      now = p[now];
    }
    ++cnt[tot];
  }
  int last = m;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] * (i / 2) >= last) {
      ans2 += last * 2;
      last = 0;
    } else {
      ans2 += cnt[i] * (i / 2) * 2;
      last -= cnt[i] * (i / 2);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (i % 2 == 0) continue;
    if (cnt[i] >= last) {
      ans2 += last;
      last = 0;
    } else {
      ans2 += cnt[i];
      last -= cnt[i];
    }
  }
  b[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (!cnt[i]) continue;
    int now = 1;
    while (now <= cnt[i]) {
      b |= (b << (now * i));
      cnt[i] -= now;
      now *= 2;
    }
    b |= (b << (cnt[i] * i));
  }
  if (b[m])
    ans1 = m;
  else
    ans1 = m + 1;
  printf("%d %d", ans1, ans2);
  return 0;
}
