#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, k, p[N];
int cnt[N];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) scanf("%d", p + i);
  bitset<N> vis;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    int cur = i, cnt = 0;
    while (!vis[cur]) {
      cnt++;
      vis[cur] = 1;
      cur = p[cur];
    }
    v.push_back(cnt);
  }
  sort(v.begin(), v.end());
  int tmp = k;
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    cnt[v[i]]++;
    int x = min(tmp, v[i] / 2);
    ans += x * 2;
    v[i] -= x * 2;
    tmp -= x;
  }
  for (int i = 0; i < v.size(); i++) {
    int x = min(tmp, v[i]);
    ans += x;
    tmp -= x;
  }
  vis.reset();
  vis[0] = 1;
  int ans2 = k + 1;
  for (int i = 1; i <= k; i++) {
    if (i > 100) {
      for (int j = 0; j < cnt[i]; j++) {
        vis = (vis | (vis << i));
      }
    } else {
      if (!cnt[i]) continue;
      vector<deque<int>> dq(i);
      vector<int> sum(i);
      int cur = 0;
      for (int j = 0; j <= k; j++) {
        dq[cur].push_back(vis[j]);
        sum[cur] += vis[j];
        if (sum[cur]) vis[j] = 1;
        if (dq[cur].size() > cnt[i]) {
          sum[cur] -= dq[j % i].front();
          dq[cur].pop_front();
        }
        ++cur;
        if (cur == i) cur = 0;
      }
    }
  }
  if (vis[k]) ans2 = k;
  cout << ans2 << ' ' << ans << '\n';
  return 0;
}
