#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int used[N], a[N];
map<int, int> num;
bitset<N> bs;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; (i) < (n); ++i) {
    cin >> a[i];
    a[i]--;
  }
  vector<int> len;
  for (int i = 0; (i) < (n); ++i) {
    if (used[i]) continue;
    int v = i, l = 0;
    while (!used[v]) {
      used[v] = 1;
      l++;
      v = a[v];
    }
    len.push_back(l);
  }
  sort((len).begin(), (len).end());
  int mx = 0, odd = 0, kk = k;
  for (int x : len) {
    if (x & 1) odd++;
    mx += min(x / 2, kk) * 2;
    kk -= min(x / 2, kk);
  }
  mx += min(odd, kk);
  int mn = k;
  for (int l : len) {
    num[l]++;
  }
  set<int> lens;
  for (int l : len) lens.insert(l);
  auto it = lens.begin();
  while (it != lens.end()) {
    int l = *it;
    int cnt = num[l];
    if (cnt <= 2) {
      it++;
      continue;
    }
    int rem = cnt - 1;
    if (rem & 1) rem--;
    lens.insert(l * 2);
    num[l * 2] += rem / 2;
    num[l] -= rem;
    it++;
  }
  bs[0] = 1;
  for (pair<int, int> p : num) {
    int val = p.first;
    for (int i = 0; (i) < (p.second); ++i) {
      bs = bs | (bs << val);
    }
  }
  if (bs[k] == 0) mn++;
  cout << mn << " " << mx << '\n';
  return 0;
}
