#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int p[N], a[N];
vector<int> v;
int wu[N * 5];
int vis[N];
int dp[N];
int du[N];
int main() {
  int n, kk;
  scanf("%d%d", &n, &kk);
  int kk1 = kk;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    int num = 0;
    int k = i;
    while (!vis[k]) {
      vis[k] = 1;
      num++;
      k = a[k];
    }
    v.push_back(num);
    du[num]++;
  }
  sort(v.begin(), v.end());
  int num = 0;
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    int tt = v[i] >> 1;
    if (kk <= tt)
      ans += kk << 1, kk = 0;
    else
      kk -= tt, ans += tt << 1;
    if (v[i] & 1) num++;
  }
  ans += min(kk, num);
  int cnt = 0;
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 0; i < v.size(); i++) {
    for (int j = 1; du[v[i]]; j <<= 1) {
      int hhh = min(du[v[i]], j);
      wu[cnt++] = hhh * v[i];
      du[v[i]] -= hhh;
    }
  }
  int ans2 = kk1;
  dp[0] = 1;
  for (int i = 0; i < cnt; i++) {
    for (int j = kk1; j >= wu[i]; j--)
      if (dp[j - wu[i]]) dp[j] = dp[j - wu[i]];
  }
  if (!dp[kk1]) ans2++;
  printf("%d %d\n", ans2, ans);
}
