#include <bits/stdc++.h>
using namespace std;
long long p[(long long)(1e6 + 5)];
bool seen[(long long)(1e6 + 5)];
long long cnt;
bool dp[(long long)(1e6 + 5)];
void dfs(long long u) {
  seen[u] = true;
  cnt++;
  if (!seen[p[u]]) dfs(p[u]);
}
void solve() {
  long long n, k;
  cin >> n >> k;
  for (long long i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  vector<long long> vs;
  for (long long i = 0; i < n; i++) {
    if (!seen[i]) {
      cnt = 0;
      dfs(i);
      vs.push_back(cnt);
    }
  }
  long long minans = 0, maxans = 0;
  long long n0 = 0, n1 = 0, n2 = 0;
  for (long long i = 0; i < vs.size(); i++) {
    long long t2 = vs[i] / 2;
    long long t1 = vs[i] % 2;
    n0 += vs[i] - t2 - t1;
    n1 += t1;
    n2 += t2;
  }
  if (k <= n2) {
    maxans += k * 2;
  } else if (k <= n1 + n2) {
    maxans = n2 * 2 + (k - n2);
  } else {
    maxans = n2 * 2 + n1;
  }
  vector<long long> vs2;
  sort(vs.begin(), vs.end());
  long long cntSmall[1005] = {0};
  for (long long i = 0; i < vs.size(); i++) {
    if (vs[i] <= 1000)
      cntSmall[vs[i]]++;
    else
      vs2.push_back(vs[i]);
  }
  for (long long i = 1; i <= 1000; i++) {
    long long pp = 1;
    bool h = false;
    while (cntSmall[i]) {
      if (cntSmall[i] % 2) {
        cntSmall[i]--;
        vs2.push_back(i * pp);
        h = true;
      } else {
        if (!h) {
          vs2.push_back(i * pp);
          vs2.push_back(i * pp);
          cntSmall[i] -= 2;
        }
        cntSmall[i] /= 2;
        pp *= 2;
        h = false;
      }
    }
  }
  dp[0] = true;
  sort(vs2.begin(), vs2.end());
  long long ssum = 0;
  for (long long i = 0; i < vs2.size(); i++) {
    ssum += vs2[i];
    for (long long j = ssum; j >= 0; j--) {
      if (dp[j] && j + vs2[i] < (long long)(1e6 + 5)) dp[j + vs2[i]] = true;
    }
  }
  if (dp[k])
    minans = k;
  else
    minans = k + 1;
  cout << minans << " " << maxans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
