#include <bits/stdc++.h>
using namespace std;
constexpr static int MAXN = 1e6 + 10;
int n, k;
int p[MAXN];
bool vis[MAXN];
bool reach[MAXN];
vector<vector<int>> cycles;
int solve1() {
  unordered_map<int, int> m;
  for (auto& c : cycles) m[-c.size()]++;
  reach[0] = true;
  int sum = 0;
  for (auto& kv : m) {
    int len = -kv.first;
    int cnt = kv.second;
    for (int i = sum; i >= 0; i--) {
      if (reach[i]) {
        for (int j = 1; j <= cnt && i + j * len <= k; j++) {
          if (reach[i + j * len]) break;
          reach[i + j * len] = true;
        }
        if (reach[k]) return k;
      }
    }
    sum += cnt * len;
  }
  if (reach[k]) return k;
  return k + 1;
}
int solve2() {
  int odd = 0;
  int total = 0;
  int used = 0;
  for (auto& c : cycles) {
    int len = c.size();
    if (len % 2 == 1) odd++;
    int cur = min(len / 2, k - used);
    used += cur;
    total += 2 * cur;
  }
  total += min(k - used, odd);
  return total;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
    p[i]--;
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    vector<int> c;
    c.push_back(i);
    vis[i] = true;
    int j = i;
    while (p[j] != i) {
      j = p[j];
      c.push_back(j);
      vis[j] = true;
    }
    cycles.push_back(c);
  }
  printf("%d %d\n", solve1(), solve2());
}
