#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
map<int, int> mp;
int p[maxn];
bool vis[maxn];
bitset<maxn> f;
int main() {
  int n, k, i, j, l, s1, s2, a, b;
  s1 = s2 = 0;
  scanf("%d%d", &n, &k);
  for (i = 1; i <= n; i++) scanf("%d", &p[i]);
  for (i = 1; i <= n; i++) {
    if (!vis[i]) {
      j = p[i];
      l = 1;
      while (j != i) {
        vis[j] = 1;
        j = p[j];
        l++;
      }
      mp[l]++;
      s2 += l / 2;
    }
  }
  if (s2 >= k)
    s2 = k * 2;
  else
    s2 += k;
  s2 = min(n, s2);
  f[0] = 1;
  for (auto u : mp) {
    a = u.first;
    b = u.second;
    j = 0;
    for (i = 0; j + (1 << i) < b; i++) {
      f |= f << (a * (1 << i));
      j |= 1 << i;
    }
    b -= j;
    f |= f << (a * b);
    if (f[k]) break;
  }
  s1 = k + (f[k] != 1);
  printf("%d %d\n", s1, s2);
  return 0;
}
