#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using db = double;
const int mxn = 1000006;
int n, k;
int a[mxn];
bool v[mxn];
int cnt;
vi s;
void dfs(int x) {
  if (v[x]) return;
  ++cnt;
  v[x] = true;
  dfs(a[x]);
}
int calMax() {
  int c2 = 0, c1 = 0;
  for (auto i : s) {
    c2 += i / 2;
    c1 += i % 2;
  }
  int re = 0;
  if (k <= c2) return k * 2;
  if (k <= c2 + c1) return c2 * 2 + (k - c2) * 1;
  return c2 * 2 + c1;
}
int w[mxn];
bool f[mxn];
bool knapsack() {
  for (auto i : s) ++w[i];
  int m = min(k, n - k);
  f[0] = true;
  for (int i = 1; i <= n; ++i)
    if (w[i])
      for (int j = m; j >= 0; --j)
        if (f[j])
          for (int k = 1, p = j + i; k <= w[i] && p <= m && !f[p]; ++k, p += i)
            f[p] = true;
  return f[m];
}
int calMin() { return k + (knapsack() ? 0 : 1); }
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i)
    if (!v[i]) {
      dfs(i);
      s.push_back(cnt);
      cnt = 0;
    }
  cout << calMin() << " " << calMax() << endl;
  return 0;
}
