#include <bits/stdc++.h>
using namespace std;
int v[1000005], c[1000005];
bool vis[1000005];
bitset<1000005> b;
bool subset_sum(int n, int sum) {
  b.set(0);
  for (int i = 1; i <= n; i++)
    if (c[i]) {
      int x = 1;
      while (c[i] >= x) {
        b |= (b << (i * x));
        c[i] -= x;
        x *= 2;
      }
      b |= (b << (c[i] * i));
    }
  return (b[sum] == 1);
}
int main() {
  int n, k;
  int pair = 0, odd = 0;
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    int len = 0;
    int u = i;
    while (!vis[u]) {
      vis[u] = 1;
      len++;
      u = v[u];
    }
    odd += (len % 2);
    pair += len / 2;
    c[len]++;
  }
  int ans_min = k + 1 - subset_sum(n, k);
  int ans_max = 0;
  if (pair > k)
    ans_max = 2 * k;
  else
    ans_max = 2 * pair + min((k - pair), odd);
  printf("%d %d\n", ans_min, ans_max);
  return 0;
}
