#include <bits/stdc++.h>
using namespace std;
using namespace chrono;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;
const int INF = 2000000000;
const ll LLINF = 9000000000000000000;
template <size_t N>
struct fbitset {
  size_t h = 0;
  ull data[(N + 63) / 64];
  fbitset() { memset(data, 0, sizeof(ull) * ((N + 63) / 64)); }
  void settrue(size_t i) {
    h = max(h, i / 64);
    data[i / 64] |= (1ULL << (i % 64));
  }
  void setfalse(size_t i) { data[i / 64] &= (~(1ULL << (i % 64))); }
  bool get(size_t i) { return bool(1ULL & (data[i / 64] >> (i % 64))); }
  void orshift(size_t s) {
    size_t d = s / 64;
    if ((N - 1) / 64 < d) return;
    size_t m = s - 64 * d;
    data[(N - 1) / 64] |= (data[(N - 1) / 64 - d] << m);
    for (int b = min(h, (N - 1) / 64 - d - 1); b >= 0; --b) {
      data[b + d] |= (data[b] << m);
      data[b + d + 1] |= (data[b] >> (64 - m));
    }
    h += d + 1;
  }
};
bool test(vi &cyc, ll k) {
  while (!cyc.empty() && cyc.back() > k) cyc.pop_back();
  if (cyc.empty()) return k == 0;
  if (cyc.back() == k) return true;
  fbitset<1000001> dp;
  dp.settrue(0);
  for (size_t l = 0, r = 0; l < cyc.size(); l = r) {
    while (r < cyc.size() && cyc[l] == cyc[r]) ++r;
    if (r >= k / cyc[l] && l < r - k / cyc[l]) l = r - k / cyc[l];
    for (int i = 1; i <= int(r - l); i <<= 1) {
      dp.orshift(i * cyc[l]);
      l += i;
    }
    if (l < r) dp.orshift(r - l);
  }
  return dp.get(k);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vi p(n, 0LL);
  for (ll &v : p) cin >> v, --v;
  if (k <= 1) {
    cout << (2 * k) << ' ' << (2 * k) << endl;
    return 0;
  }
  vi cyc;
  vb vis(n, false);
  for (int i = 0; i < n; ++i) {
    if (vis[i]) continue;
    int j = i, l = 0;
    while (!vis[j]) {
      vis[j] = true;
      j = p[j];
      ++l;
    }
    cyc.push_back(l);
  }
  sort(cyc.begin(), cyc.end());
  ll maxans = 0LL, minans = 0LL;
  ll kk = k;
  for (ll v : cyc) {
    if (v & 1) continue;
    if (kk >= v / 2LL) {
      maxans += v;
      kk -= v / 2LL;
    } else {
      maxans += 2LL * kk;
      kk -= kk;
    }
  }
  ll e = 0LL;
  for (ll v : cyc) {
    if (v & 1) {
      if (kk >= (v - 1LL) / 2LL) {
        maxans += v - 1LL;
        kk -= (v - 1LL) / 2LL;
        ++e;
      } else {
        maxans += 2LL * kk;
        kk -= kk;
      }
    }
  }
  maxans += min(kk, e);
  minans = k + 1LL;
  if (k > n - k) k = n - k;
  if (test(cyc, k)) --minans;
  cout << minans << ' ' << maxans << endl;
  return 0;
}
