#include <bits/stdc++.h>
#pragma GCC target("arch=corei7-avx")
char in() {
  static char buf[1000001], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <class Tp>
void read(register Tp &s) {
  s = 0;
  register bool neg = 0;
  register char c = in();
  while (c < '0' || c > '9') {
    if (c == '-') neg = 1;
    c = in();
  }
  while (c >= '0' && c <= '9') s = (s << 1) + (s << 3) + c - 48, c = in();
  s = (neg ? -s : s);
}
int n, k, cnt, a[1000005], p[1000005], v[1000005];
bool vis[1000005];
std::bitset<1000005> f;
std::vector<int> lp;
void solve1() {
  cnt = 1;
  v[1] = lp[0];
  p[1] = 1;
  for (int i = 1; i < (int)lp.size(); ++i) {
    if (lp[i] == lp[i - 1])
      ++p[cnt];
    else
      v[++cnt] = lp[i], p[cnt] = 1;
  }
  f[0] = 1;
  for (int i = 1; i <= cnt; ++i) {
    for (int l = 1; l <= p[i]; p[i] -= l, l <<= 1) {
      f |= (f << (l * v[i]));
    }
    f |= (f << (p[i] * v[i]));
  }
  if (f[k])
    printf("%d ", k);
  else
    printf("%d ", k + 1);
}
void solve2() {
  int odd = 0, res = 0;
  for (int i = 0; i < (int)lp.size(); ++i) {
    if (lp[i] / 2 <= k)
      res += lp[i] / 2 * 2, k -= lp[i] / 2;
    else
      res += 2 * k, k = 0;
    odd += (lp[i] & 1);
  }
  res += std::min(k, odd);
  printf("%d", res);
}
int main() {
  read(n);
  read(k);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      int cnt = 0, t = i;
      while (!vis[t]) vis[t] = 1, ++cnt, t = a[t];
      lp.push_back(cnt);
    }
  std::sort(lp.begin(), lp.end());
  solve1();
  solve2();
  return 0;
}
