#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int p[N], mark[N], cnt[N];
vector<int> vec;
bitset<N> dp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> p[i];
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    if (mark[i]) continue;
    int v = i, len = 0;
    while (!mark[v]) mark[v] = 1, len++, v = p[v];
    cnt[len]++;
    sum += len - len % 2;
  }
  int mx = min(n, k + min(k, sum / 2));
  for (int i = 1; i <= n; i++) {
    int pw = 1;
    while (pw <= cnt[i]) vec.push_back(i * pw), cnt[i] -= pw, pw *= 2;
    if (cnt[i]) vec.push_back(i * cnt[i]);
  }
  int cp = k;
  k = min(k, n - k);
  dp[0] = 1;
  for (int x : vec) {
    dp |= dp << x;
    if (dp[k]) break;
  }
  int mn = cp + 1 - dp[k];
  cout << mn << ' ' << mx << '\n';
  return 0;
}
