#include <bits/stdc++.h>
using namespace std;
static int visited[1000005], k, cyc[1000005];
bitset<1000005> dp;
int main() {
  static int loop, i, x, n, p[1000005], mi, ma, lo, op;
  scanf("%d %d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d", p + i);
    p[i]--;
  }
  lo = op = 0;
  for (i = 0; i < n; i++) {
    if (!visited[i]) {
      loop = 1;
      visited[i] = 1;
      x = p[i];
      while (!visited[x]) {
        loop++;
        visited[x] = 1;
        x = p[x];
      }
      cyc[loop]++;
      if (loop % 2) op++;
      lo += loop / 2;
    }
  }
  dp[0] = 1;
  for (int x = 1; x <= k; x++) {
    if (cyc[x] > 0) {
      i = 1;
      while (cyc[x] > 0) {
        i = min(i, cyc[x]);
        dp |= dp << (x * i);
        cyc[x] -= i;
        i *= 2;
      }
    }
  }
  if (dp[k] == 1)
    mi = k;
  else
    mi = k + 1;
  printf("%d %d\n", mi, 2 * min(lo, k) + min(k - min(lo, k), op));
  return 0;
}
