#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n, k;
  scanf("%d%d", &(n), &(k));
  static int p[int(1e6 + 5)];
  for (int i = 1, __R = n; i <= __R; i++) scanf("%d", &(p[i]));
  static bool vis[int(1e6 + 5)];
  static int cnt[int(1e6 + 5)];
  int ev = 0, od = 0;
  for (int i = 1, __R = n; i <= __R; i++)
    if (!vis[i]) {
      int x = i;
      int len = 0;
      while (!vis[x]) {
        vis[x] = true;
        len++;
        x = p[x];
      }
      cnt[len]++;
      if (len & 1) od++;
      ev += (len >> 1);
    }
  bitset<int(5e6 + 5)> dp;
  dp[0] = 1;
  for (int i = 1, __R = n; i <= __R; i++)
    if (cnt[i]) {
      int j = 1;
      while (cnt[i] > 0) {
        j = min(j, cnt[i]);
        int x = j * i;
        dp |= (dp << x);
        cnt[i] -= j;
        j <<= 1;
      }
    }
  int m = k + (1 - dp[min(k, n - k)]);
  int t = min(k, ev);
  int M = (t << 1) + min(k - t, od);
  printf("%d %d\n", m, M);
  return 0;
}
