#include <bits/stdc++.h>
using namespace std;
bitset<1000001> b;
int len[1000001];
int p[1000001];
bool flag[1000001];
int n, k;
void solve() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &(p[i]));
    p[i]--;
    flag[i] = false;
    len[i] = 0;
  }
  int c1 = 0, c2 = 0;
  for (int i = 0; i < n; i++) {
    if (flag[i]) continue;
    flag[i] = true;
    int x = p[i], cnt = 1;
    while (!flag[x]) {
      cnt++;
      flag[x] = true;
      x = p[x];
    }
    len[cnt]++;
    c1 += cnt / 2;
    c2 += cnt % 2;
  }
  b.set(n);
  for (int i = 1; i <= n; i++) {
    if (len[i] == 0) continue;
    int j = 1;
    int cnt = len[i];
    while (cnt > 0) {
      j = min(j, cnt);
      int u = j * i;
      b |= (b >> u);
      cnt -= j;
      j *= 2;
    }
  }
  int ans_min = k;
  if (!b.test(n - k)) ans_min++;
  int ans_max = 2 * k;
  if (c1 < k) ans_max = 2 * c1 + min(k - c1, c2);
  printf("%d %d\n", ans_min, ans_max);
}
int main() {
  solve();
  return 0;
}
