#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
void sync_stdio() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
}
struct Sync_stdio {
  Sync_stdio() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
  }
} _sync_stdio;
struct FAIL {
  FAIL() {
    cout << "CHANGE!!!"
         << "\n";
  }
};
int get_min(const vector<int> &cycles, int k) {
  const int N = 100;
  const int MAXN = 1000001;
  int n = cycles.size();
  vector<int> cnt(N);
  for (int i = (0); i < (n); ++i) {
    if (cycles[i] >= N) {
      continue;
    }
    ++cnt[cycles[i]];
  }
  bitset<MAXN> res;
  res.set(0);
  for (int i = (1); i < (N); ++i) {
    bitset<MAXN> res2;
    for (int j = (0); j < (i); ++j) {
      int last = -1;
      for (int k = j, t = 0; k < MAXN; k += i, ++t) {
        if (res.test(k)) {
          last = t;
        }
        if (last != -1 && t - last <= cnt[i]) {
          res2.set(k);
        }
      }
    }
    res = res2;
  }
  for (int i = (0); i < (n); ++i) {
    if (cycles[i] >= N) {
      res = res | (res << cycles[i]);
    }
  }
  return res.test(k) ? k : k + 1;
}
int get_max(const vector<int> &cycles, int k) {
  int n = cycles.size();
  int two = 0;
  int one = 0;
  for (int i = (0); i < (n); ++i) {
    two += cycles[i] / 2;
    one += cycles[i] % 2;
  }
  if (k <= two) {
    return 2 * k;
  }
  if (k > two + one) {
    return accumulate(cycles.begin(), cycles.end(), 0LL);
  }
  return 2 * two + (k - two);
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int __i = 0; __i < (n); ++__i) cin >> p[__i];
  ;
  for (int i = (0); i < (n); ++i) {
    --p[i];
  }
  vector<int> cycles;
  vector<int> used(n);
  for (int i = (0); i < (n); ++i) {
    if (used[i]) {
      continue;
    }
    int t = i;
    int res = 0;
    do {
      t = p[t];
      used[t] = 1;
      ++res;
    } while (t != i);
    cycles.push_back(res);
  }
  cout << get_min(cycles, k) << " " << get_max(cycles, k) << "\n";
  return 0;
}
