#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 6, border = 100;
bool used[MAX];
int cnt[MAX];
bitset<MAX> dp, calc;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int p[n];
  for (int(i) = (0); (i) < (n); ++i) {
    cin >> p[i];
    --p[i];
  }
  int c1 = 0, c2 = 0;
  vector<int> w;
  for (int(i) = (0); (i) < (n); ++i) {
    if (used[i]) continue;
    int len = 0, v = i;
    while (!used[v]) {
      used[v] = true;
      ++len;
      v = p[v];
    }
    w.push_back(len);
    c1 += len / 2;
    c2 += len % 2;
  }
  dp[0] = true;
  for (auto el : w)
    if (el >= border)
      dp |= dp << el;
    else
      cnt[el]++;
  calc[0] = true;
  for (int(val) = (1); (val) < (border); ++val)
    for (int(i) = (0); (i) < (val); ++i) {
      int cur = 1e9;
      for (int j = i; j < MAX; j += val) {
        if (calc[j]) cur = 0;
        if (cur <= cnt[val]) calc[j] = true;
        ++cur;
      }
    }
  bool flag = false;
  for (int(i) = (0); (i) < (k + 1); ++i)
    if (dp[i] && calc[k - i]) flag = true;
  if (flag)
    cout << k << ' ';
  else
    cout << k + 1 << ' ';
  int ans_max = min(k, c1) * 2;
  k -= min(k, c1);
  ans_max += min(k, c2);
  cout << ans_max;
  return 0;
}
