#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int N, K;
int A[MAXN];
bool vis[MAXN];
vector<int> vlen;
int cnt[MAXN];
int getmin() {
  bitset<MAXN> b;
  b[0] = true;
  for (int i = 1; i <= N; i++) {
    for (int c = cnt[i], step = 1; c; step *= 2) {
      step = min(step, c);
      b |= (b << (i * step));
      c -= step;
    }
  }
  return K + !b[K];
}
int getmax() {
  int cnt1 = 0, cnt2 = 0;
  for (int x : vlen) {
    cnt1 += x % 2;
    cnt2 += x / 2;
  }
  int ck = K;
  int ans = 0;
  ans += 2 * min(ck, cnt2);
  ck -= min(ck, cnt2);
  ans += min(ck, cnt1);
  return ans;
}
int main() {
  scanf("%d %d", &N, &K);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 1; i <= N; i++) {
    if (vis[i]) {
      continue;
    }
    int clen = 0;
    for (int j = i; !vis[j]; j = A[j]) {
      clen++;
      vis[j] = true;
    }
    cnt[clen]++;
    vlen.push_back(clen);
  }
  printf("%d %d\n", getmin(), getmax());
}
