#include <bits/stdc++.h>
using namespace std;
using std::bitset;
const double Pi = acos(-1);
namespace fastIO {
template <class T>
inline void read(T& x) {
  x = 0;
  bool fu = 0;
  char ch = 0;
  while (ch > '9' || ch < '0') {
    ch = getchar();
    if (ch == '-') fu = 1;
  }
  while (ch <= '9' && ch >= '0') x = (x * 10 - 48 + ch), ch = getchar();
  if (fu) x = -x;
}
inline int read() {
  int x = 0;
  bool fu = 0;
  char ch = 0;
  while (ch > '9' || ch < '0') {
    ch = getchar();
    if (ch == '-') fu = 1;
  }
  while (ch <= '9' && ch >= '0') x = (x * 10 - 48 + ch), ch = getchar();
  return fu ? -x : x;
}
template <class T, class... Args>
inline void read(T& t, Args&... args) {
  read(t);
  read(args...);
}
char _n_u_m_[40];
template <class T>
inline void write(T x) {
  if (x == 0) {
    putchar('0');
    return;
  }
  T tmp = x > 0 ? x : -x;
  if (x < 0) putchar('-');
  register int cnt = 0;
  while (tmp > 0) {
    _n_u_m_[cnt++] = tmp % 10 + '0';
    tmp /= 10;
  }
  while (cnt > 0) putchar(_n_u_m_[--cnt]);
}
template <class T>
inline void write(T x, char ch) {
  write(x);
  putchar(ch);
}
}  // namespace fastIO
using namespace fastIO;
int n, k, v[1000002], cnt, p[1000002], m, res, orz;
bool vis[1000002];
int ak[1000002];
inline void dfs(int pos) {
  if (vis[pos]) return;
  vis[pos] = 1;
  ++cnt;
  dfs(p[pos]);
}
bitset<1000002> dp, temp;
inline void ksm(int n, int num) {
  register int i = 1;
  temp = dp | (dp << i * num);
  while (i * 2 <= n) {
    temp |= (temp << i * num);
    i <<= 1;
  }
  if (i != n) temp |= (temp << (n - i) * num);
}
inline bool check() {
  dp[0] = 1;
  for (register int i = 1, iend = n; i <= iend; ++i) {
    if (ak[i]) ksm(ak[i], i), dp = temp;
  }
  return dp[k];
}
int main() {
  cin >> n >> k;
  for (register int i = 1, iend = n; i <= iend; ++i) read(p[i]);
  for (register int i = 1, iend = n; i <= iend; ++i)
    if (!vis[i]) dfs(i), v[++m] = cnt, ak[cnt]++, orz += (cnt & 1), cnt = 0;
  write(check() ? k : k + 1);
  putchar(' ');
  if (k <= (n - orz) / 2)
    write(k * 2);
  else
    write(min(n, n - orz + (k - (n - orz) / 2)));
  return 0;
}
