#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int n, k;
int p[MAXN];
bool read() {
  if (scanf("%d%d", &n, &k) < 2) {
    return 0;
  }
  for (int i = 0; i < int(n); ++i) {
    scanf("%d", &p[i]);
    --p[i];
  }
  return 1;
}
bool used[MAXN];
bool dp[2][MAXN];
void solve() {
  vector<int> lens;
  memset(used, 0, sizeof used);
  for (int i = 0; i < int(n); ++i) {
    if (!used[i]) {
      int cur = 1;
      int j = p[i];
      while (j != i) {
        ++cur;
        used[j] = 1;
        j = p[j];
      }
      lens.push_back(cur);
    }
  }
  memset(dp, 0, sizeof dp);
  vector<int> cnt(n + 1, 0);
  for (int len : lens) {
    ++cnt[len];
  }
  int c = 0;
  dp[c][0] = 1;
  int pref = 0;
  for (int len = 1; len <= n; ++len) {
    int Cnt = cnt[len];
    if (!Cnt) {
      continue;
    }
    Cnt *= len;
    pref += Cnt;
    for (int shift = 0; shift < int(len); ++shift) {
      int sum = 0;
      for (int i = shift; i <= pref; i += len) {
        dp[c ^ 1][i] = sum > 0 || dp[c][i];
        sum += dp[c][i];
        if (i - Cnt >= 0) {
          sum -= dp[c][i - Cnt];
        }
      }
    }
    memset(dp[c], 0, sizeof dp[c]);
    c ^= 1;
  }
  if (dp[c][k]) {
    printf("%d ", k);
  } else {
    printf("%d ", k + 1);
  }
  int mx = 0;
  for (int len : lens) {
    if (len % 2 == 0) {
      int use = min(k, len / 2);
      mx += use * 2;
      k -= use;
    }
  }
  for (int len : lens) {
    if (len % 2 == 1) {
      int use = min(k, len / 2);
      mx += use * 2;
      k -= use;
    }
  }
  for (int len : lens) {
    if (len % 2 == 1 && k > 0) {
      --k;
      ++mx;
    }
  }
  printf("%d\n", mx);
}
int main() {
  while (read()) {
    solve();
    break;
  }
  return 0;
}
