#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60777216")
using namespace std;
int n, k;
int a[1 << 20];
int d[1 << 20];
bitset<1 << 20> u;
bool good(int t) {
  u[0] = 1;
  for (int i = (0); i < (1 << 20); i++)
    if (d[i]) {
      int z = d[i];
      int j = 1;
      while (z) {
        j = min(j, z);
        z -= j;
        u = u | (u << (j * i));
        j *= 2;
      }
    }
  return u[t];
}
int main() {
  cin >> n >> k;
  for (int i = (0); i < (n); i++) scanf("%d", a + i), a[i]--;
  for (int i = (0); i < (n); i++)
    if (a[i] != -1) {
      int t = i;
      int num = 0;
      while (a[t] != -1) {
        int nt = a[t];
        a[t] = -1;
        t = nt;
        num++;
      }
      d[num]++;
    }
  int mn = k;
  int mx = 0;
  int r = k;
  for (int i = (0); i < (1 << 20); i++) {
    int z = min(i / 2 * d[i], r);
    mx += z * 2;
    r -= z;
  }
  for (int i = (0); i < (1 << 20); i++)
    if (i % 2 == 1 && r) {
      int z = min(d[i], r);
      r -= z;
      mx += z;
    }
  int tk = k;
  if (tk > n - k) tk = n - k;
  if (!good(tk)) mn++;
  cout << mn << ' ' << mx << endl;
  return 0;
}
