#include <bits/stdc++.h>
using namespace std;
const int NK = 1e6 + 10;
int p[NK], qtd[NK];
bool seen[NK];
int dp[NK];
int get_minimum(int n, int k) {
  int lim = min(k, n - k);
  vector<pair<int, int>> cycles;
  for (int i = 1; i <= n; i++) {
    if (qtd[i]) cycles.push_back({i, qtd[i]});
  }
  dp[0] = 0;
  for (int i = 1; i <= lim; i++) {
    dp[i] = -1;
  }
  for (auto c : cycles) {
    int val = c.first, qtd = c.second;
    for (int i = 0; i <= lim; i++) {
      if (dp[i] != -1) {
        dp[i] = 0;
      } else if (i >= val && dp[i - val] != -1 && dp[i - val] < qtd) {
        dp[i] = dp[i - val] + 1;
      } else {
        dp[i] = -1;
      }
    }
  }
  return dp[lim] != -1 ? k : k + 1;
}
int get_maximum(int n, int k) {
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    cnt += i / 2 * qtd[i];
  }
  return min(min(cnt, k) * 2 + k - min(cnt, k), n);
}
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &p[i]);
  }
  for (int i = 1; i <= n; i++)
    if (!seen[i]) {
      int u = i, cnt = 0;
      while (!seen[u]) {
        seen[u] = true;
        u = p[u];
        cnt++;
      }
      qtd[cnt]++;
    }
  printf("%d %d\n", get_minimum(n, k), get_maximum(n, k));
  return 0;
}
