#include <bits/stdc++.h>
using namespace std;
int P[1000005];
bool used[1000005];
map<int, int> num;
bool can[2][1000005];
int main() {
  int N, K;
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; ++i) {
    scanf("%d", &P[i]);
  }
  vector<int> sizs;
  for (int i = 1; i <= N; ++i) {
    if (used[i]) continue;
    int siz = 1;
    used[i] = true;
    for (int x = P[i]; x != i; x = P[x]) {
      used[x] = true;
      ++siz;
    }
    sizs.push_back(siz);
    ++num[siz];
  }
  int n = sizs.size();
  int mn;
  can[0][0] = 1;
  int f = 0;
  int sofar = 0;
  for (auto y : num) {
    f = 1 - f;
    int x = y.first;
    int nn = y.second;
    int xnn = x * nn;
    sofar += x * nn;
    for (int start = 0; start < x; ++start) {
      int tot = 0;
      for (int s = start; s <= sofar; s += x) {
        tot += can[!f][s];
        can[f][s] = tot;
        if (s >= xnn) tot -= can[!f][s - xnn];
      }
    }
  }
  if (!K)
    mn = 0;
  else if (can[f][K])
    mn = K;
  else
    mn = K + 1;
  int mx, mx2s = 0;
  for (int x : sizs) {
    mx2s += x / 2;
  }
  if (K <= mx2s)
    mx = K * 2;
  else
    mx = min(N, mx2s * 2 + (K - mx2s));
  printf("%d %d\n", mn, mx);
}
