#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  if (a >= mod) a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    if (res >= mod) res %= mod;
    a = a * a;
    if (a >= mod) a %= mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
const int maxn = 1000010;
const int inf = INT_MAX;
bitset<maxn> dp;
int c[maxn], p[maxn];
int main() {
  int n, k, i, j;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) scanf("%d", p + i);
  int odd = 0, val = 0;
  for (int i = 1; i <= n; i++) {
    if (p[i] == 0) continue;
    j = i;
    int l = 0;
    while (p[j] != 0) {
      l++;
      int jj = p[j];
      p[j] = 0;
      j = jj;
    }
    if (l & 1) odd++;
    c[l]++;
    val += l / 2;
  }
  if (val > k) val = k;
  int maxi = 2 * val;
  if (k - val) maxi += min(odd, k - val);
  for (int i = 1; i <= n; i++)
    if (c[i] > 2) {
      c[2 * i] += (c[i] - 1) / 2;
      c[i] = (c[i] - 1) & 1;
      ;
      c[i]++;
    }
  dp.set(0);
  for (int i = 1; i <= n; i++)
    if (c[i] == 0)
      continue;
    else {
      dp |= dp << i;
      if (c[i] > 1) dp |= dp << i;
    }
  if (dp[k] == 0) k++;
  cout << k << " " << maxi;
  cin.get();
  cin.get();
  return 0;
}
