#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const int nax = 1e6 + 5;
int cnt[nax], p[nax];
bool vis[nax];
bitset<nax> dp;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  int seco = 0;
  for (int i = 1; i <= n; ++i) scanf("%d", &p[i]);
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) {
      int size = 0;
      do {
        vis[i] = true;
        ++size;
        i = p[i];
      } while (!vis[i]);
      seco += size / 2;
      ++cnt[size];
    }
  dp[0] = true;
  for (int size = 1; size <= n; ++size)
    if (cnt[size]) {
      int x = cnt[size];
      for (int i = 0; x; ++i) {
        dp |= dp << (size << i);
        x -= 1 << i;
        if (x & (1 << i)) {
          dp |= dp << (size << i);
          x -= 1 << i;
        }
      }
    }
  int strong = min(seco, k);
  printf("%d %d\n", k + !dp[k], min(n, strong * 2 + (k - strong)));
}
