#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 6;
int n, k;
vector<int> adj[MAX];
int p[MAX];
bool visited[MAX];
bitset<MAX> dp;
void dfs(int source, int &total) {
  total++;
  visited[source] = true;
  for (auto &each : adj[source]) {
    if (!visited[each]) {
      dfs(each, total);
    }
  }
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = int(1); i < int(n + 1); i++) {
    scanf("%d", p + i);
    adj[i].push_back(p[i]);
  }
  vector<int> sizes;
  int free = 0;
  for (int i = int(1); i < int(n + 1); i++) {
    if (!visited[i]) {
      int total = 0;
      dfs(i, total);
      free += total / 2;
      sizes.push_back(total);
    }
  }
  sort(sizes.begin(), sizes.end());
  free = min(free, k);
  int left = max(0, n - 2 * free);
  left = min(left, k - free);
  int maximum = free * 2 + left;
  map<int, int> app;
  set<int> all;
  for (auto &each : sizes) {
    app[each]++;
    all.insert(each);
  }
  for (auto it = all.begin(); it != all.end(); it++) {
    int each = *it;
    int cnt = app[each];
    if (cnt <= 2) {
      continue;
    }
    int total = 1;
    cnt--;
    if (cnt & 1) {
      total++;
      cnt--;
    }
    if (cnt > 0) {
      all.insert(2 * each);
      app[2 * each] += cnt / 2;
    }
    app[each] = total;
  }
  dp.set(0);
  for (auto &each : app) {
    if (each.first > k) {
      break;
    }
    assert(each.second <= 2);
    for (int i = int(0); i < int(each.second); i++) {
      dp = dp | (dp << each.first);
    }
  }
  int minimum = k + (dp[k] == 0);
  printf("%d %d\n", minimum, maximum);
  return 0;
}
