#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 1000 + 10, SQ = 177;
int num[N], p[N];
bitset<N> d, mark;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k, a1(0), a2(0), mx(0), mn(0);
  scanf("%d %d", &n, &k);
  mn = k;
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    if (!mark[i]) {
      int pt(p[i]), cnt(0);
      while (pt != i) {
        mark[pt] = 1;
        pt = p[pt];
        cnt++;
      }
      mark[pt] = 1, cnt++;
      num[cnt]++;
      a1 += cnt / 2, a2 += cnt / 2;
      a2 += cnt % 2;
    }
  }
  if (k <= a1)
    mx = k * 2;
  else if (k <= a2)
    mx = a1 * 2 + (k - a1);
  else
    mx = n;
  d[0] = 1;
  for (int i = SQ; i <= n; i++) {
    for (int j = 0; j < num[i]; j++) d |= (d << i);
  }
  for (int i = 2; i < SQ; i++) {
    if (num[i]) {
      for (int j = n; j >= 0; j--) {
        if (d[j]) {
          int t = num[i], pt(j + i);
          while (pt <= n && !d[pt] && t) {
            d[pt] = 1;
            t--;
            pt += i;
          }
        }
      }
    }
  }
  if (!d[k]) mn++;
  cout << mn << " " << mx << endl;
  return 0;
}
