#include <bits/stdc++.h>
using namespace std;
int const INF = 100 + (int)1e9;
long long const INFL = 100 + (long long)1e18;
long double const PI = 3.141592653589793238462643L;
mt19937 tw(960172);
bool is_prime(long long x) {
  for (long long y = 2; y * y <= x; ++y)
    if (x % y == 0) return 0;
  return x > 1;
}
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(tw) % (y - x + 1) + x;
}
long long sqr(int a) { return (long long)a * a; }
template <class T>
T sqr(T const& a) {
  return a * a;
}
long long gcd(long long a, long long b) {
  while (b > 0) {
    long long t = a % b;
    a = b;
    b = t;
  }
  return a;
}
int const size = 20200200;
char put[size];
int ptr = 0;
int next_int() {
  while (put[ptr] < 33) ++ptr;
  int ret = 0;
  while (put[ptr] > 32) ret = 10 * ret + put[ptr++] - '0';
  return ret;
}
int const N = 1100100;
int p[N];
int lens[N];
bool used[N];
bool has[N];
void solve() {
  fread(put, 1, size, stdin);
  int n = next_int();
  int k = next_int();
  for (int i = 0; i < n; ++i) p[i] = next_int() - 1;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (used[i]) continue;
    int cur = 0;
    for (int v = i; !used[v]; v = p[v]) {
      used[v] = 1;
      ++cur;
    }
    lens[cnt++] = cur;
    has[cur] = 1;
  }
  sort(lens, lens + cnt);
  int mi = 0;
  {
    int x = n - k;
    for (int i = 0; i < cnt; ++i) {
      x -= lens[i] / 2;
    }
    if (x > 0) {
      for (int i = 0; x > 0 && i < cnt; ++i) {
        if (lens[i] % 2 == 1) {
          x -= 1;
          mi += 1;
        }
      }
      if (x > 0) {
        for (int i = 0; i < cnt; ++i) {
          int here = min(lens[i] / 2, x);
          x -= here;
          mi += 2 * here;
        }
      }
    }
  }
  int ma = 0;
  {
    static bool dp[2][N];
    int cur = 0;
    dp[cur][0] = true;
    int need = min(k, n - k);
    static int const C = 500;
    static int fr[C];
    for (int i = 0; i < cnt; ++i)
      if (lens[i] < C)
        ++fr[lens[i]];
      else
        for (int x = need; x >= lens[i]; --x)
          dp[cur][x] |= dp[cur][x - lens[i]];
    for (int len = 0; len < C; ++len) {
      int k = fr[len] * len;
      if (!k) continue;
      for (int r = 0; r < len; ++r) {
        int last = -INF;
        for (int x = r; x <= need; x += len) {
          dp[!cur][x] = dp[cur][x] || x - last <= k;
          if (dp[cur][x]) last = x;
        }
      }
      cur ^= 1;
    }
    ma = dp[cur][need] ? k : k + 1;
  }
  cout << ma << ' ' << n - mi << '\n';
}
int main() {
  cout << setprecision(15) << fixed;
  int tcnt = 1;
  for (int test = 1; test <= tcnt; ++test) solve();
}
