#include <bits/stdc++.h>
using namespace std;
const long long size = 1e6 + 100;
const long long mod = 1000000007;
int n, k;
int a[size];
const int T = 100;
int ci[111];
vector<int> vi;
int dp[size];
int b[size];
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int A = 0, B = 0;
  for (int i = 1; i <= n; i++)
    if (a[i]) {
      int cnt = 0;
      int to = i;
      while (a[to]) {
        cnt++;
        int tmp = a[to];
        a[to] = 0;
        to = tmp;
      }
      if (cnt > T) {
        vi.push_back(cnt);
      } else
        ci[cnt]++;
      A += cnt / 2;
      B += cnt % 2;
    }
  memset(a, 0, sizeof(a));
  a[0] = 1;
  for (auto x : vi) {
    for (int i = k / 30 + 10; i + 1; i--)
      if (a[i]) {
        int to = i + x / 30;
        int y = x % 30;
        int mask = (1 << 30) - 1;
        long long num = a[i];
        a[to] |= ((num << y) & mask);
        a[to + 1] |= (num >> (30 - y));
      }
  }
  dp[0] = 1;
  for (int i = 1; i <= T; i++) {
    for (int s = 0; s < i; s++) {
      int tot = 0;
      for (int k = 0; s + k * i <= n; k++) {
        int rp = s + k * i;
        b[rp] = dp[rp];
        tot += b[s + k * i];
        if (k - ci[i] - 1 >= 0) tot -= b[s + (k - ci[i] - 1) * i];
        if (tot > 0) dp[rp] = 1;
      }
    }
  }
  if (n == 993 && k == 409 && 0) {
    for (int i = 0; i < size; i++)
      if (a[i]) {
      }
    int p = 247 + 108;
    cout << p << ' ' << (a[p / 30] & (1 << (p % 30))) << endl;
    cout << vi.size() << endl;
    ;
    for (auto x : vi) cout << x << endl;
    for (int i = 0; i <= k; i++)
      if (dp[i]) cout << i << ' ';
    cout << endl;
    for (int i = 0; i <= T; i++)
      if (ci[i]) cout << i << ' ' << ci[i] << endl;
  }
  int ans = 1;
  for (int i = 0; i <= k; i++)
    if (dp[k - i]) {
      if (a[i / 30] & (1 << (i % 30))) ans = 0;
    }
  cout << k + ans << ' ';
  ans = 0;
  if (k <= A)
    ans = k * 2;
  else
    ans = A * 2 + min(B, k - A);
  cout << ans << endl;
}
