#include <bits/stdc++.h>
using namespace std;
template <class C>
void mini(C &a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C &a4, C b4) {
  a4 = max(a4, b4);
}
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
template <class T>
ostream &operator<<(ostream &os, vector<T> V) {
  os << "[";
  for (auto vv : V) os << vv << ",";
  return os << "]";
}
template <class L, class R>
ostream &operator<<(ostream &os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
const long long MAX = 1e6 + 5;
bool odw[MAX];
long long p[MAX];
long long n, k;
map<long long, long long> cykl;
long long ost[MAX];
long long il[MAX];
bool licz(long long m) {
  if (m == 0) return 0;
  il[0] = 1;
  long long xx = 0;
  for (pair<long long, long long> ak : cykl) {
    long long a, kr;
    tie(a, kr) = ak;
    xx += a * kr;
    long long lim = min(xx, m);
    for (long long i = a; i <= lim; i++) {
      if (!il[i] && il[i - a]) {
        if (ost[i - a] != a) {
          il[i] = 1;
        } else {
          il[i] = il[i - a] + 1;
        }
        ost[i] = a;
        if (il[i] > kr) {
          il[i] = 0;
        }
      }
    }
    if (il[m]) return 0;
  }
  return 1;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  if (0) cout << fixed << setprecision(6);
  cin >> n >> k;
  for (long long i = (0); i <= ((long long)(n)-1); i++) {
    cin >> p[i];
    p[i]--;
  }
  for (long long i = (0); i <= ((long long)(n)-1); i++) {
    if (odw[i] == 0) {
      long long ak = i;
      long long dl = 0;
      while (!odw[ak]) {
        odw[ak] = 1;
        ak = p[ak];
        dl++;
      }
      cykl[dl]++;
    }
  }
  long long dwu = 0;
  long long jed = 0;
  for (pair<long long, long long> ak : cykl) {
    dwu += (ak.first / 2) * ak.second;
    if (ak.first & 1) {
      jed += ak.second;
    }
  }
  long long pom = min(dwu, k);
  cout << k + licz(min(k, n - k)) << " " << 2 * pom + min(k - pom, jed) << "\n";
}
