#include <bits/stdc++.h>
using namespace std;
typedef const int &ci;
const int N = 1000006;
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while ('0' <= c && c <= '9') x = 10 * x + c - '0', c = getchar();
  return x;
}
bool vis[N];
int n, k, p[N];
int cnt[N];
int f[N], ans;
int main() {
  n = read(), k = read();
  for (int i = 1; i <= n; i++) p[i] = read();
  for (int i = 1, u, tot; i <= n; i++)
    if (!vis[i]) {
      u = i, tot = 0;
      while (!vis[u]) {
        vis[u] = true;
        tot++, u = p[u];
      }
      ans += (tot >> 1);
      cnt[tot]++;
    }
  f[0] = true;
  for (int w = 1, pos, mx = 0; w <= n; w++)
    if (cnt[w]) {
      mx += w * cnt[w];
      for (int r = 0; r < w; r++) {
        pos = -0x3f3f3f3f;
        for (int i = r; i <= mx; i += w) {
          if (f[i]) pos = i;
          if ((i - pos) / w <= cnt[w]) f[i] = true;
        }
      }
    }
  printf("%d %d\n", k + 1 - f[k], min(n, k > ans ? ans + k : 2 * k));
  return 0;
}
