#include <bits/stdc++.h>
template <typename T>
class IntegerIterator
    : public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> {
 public:
  explicit IntegerIterator(T value) : value(value) {}
  IntegerIterator& operator++() {
    ++value;
    return *this;
  }
  IntegerIterator operator++(int) {
    IntegerIterator copy = *this;
    ++value;
    return copy;
  }
  IntegerIterator& operator--() {
    --value;
    return *this;
  }
  IntegerIterator operator--(int) {
    IntegerIterator copy = *this;
    --value;
    return copy;
  }
  T operator*() const { return value; }
  bool operator==(IntegerIterator rhs) const { return value == rhs.value; }
  bool operator!=(IntegerIterator rhs) const { return !(*this == rhs); }

 private:
  T value;
};
template <typename T>
class IntegerRange {
 public:
  IntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }
  IntegerIterator<T> begin() const { return IntegerIterator<T>(begin_); }
  IntegerIterator<T> end() const { return IntegerIterator<T>(end_); }

 private:
  T begin_;
  T end_;
};
template <typename T>
class ReversedIntegerRange {
 public:
  ReversedIntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }
  std::reverse_iterator<IntegerIterator<T>> begin() const {
    return std::reverse_iterator<IntegerIterator<T>>(
        IntegerIterator<T>(begin_));
  }
  std::reverse_iterator<IntegerIterator<T>> end() const {
    return std::reverse_iterator<IntegerIterator<T>>(IntegerIterator<T>(end_));
  }

 private:
  T begin_;
  T end_;
};
template <typename T>
IntegerRange<T> range(T to) {
  return IntegerRange<T>(0, to);
}
template <typename T>
IntegerRange<T> range(T from, T to) {
  return IntegerRange<T>(from, to);
}
template <typename T>
IntegerRange<T> inclusiveRange(T to) {
  return IntegerRange<T>(0, to + 1);
}
template <typename T>
IntegerRange<T> inclusiveRange(T from, T to) {
  return IntegerRange<T>(from, to + 1);
}
template <typename T>
ReversedIntegerRange<T> downrange(T from) {
  return ReversedIntegerRange<T>(from, 0);
}
template <typename T>
ReversedIntegerRange<T> downrange(T from, T to) {
  return ReversedIntegerRange<T>(from, to);
}
template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from) {
  return ReversedIntegerRange<T>(from + 1, 0);
}
template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from, T to) {
  return ReversedIntegerRange<T>(from + 1, to);
}
inline std::mt19937& randomEngine() {
  static std::random_device device;
  static std::mt19937 engine(device());
  return engine;
}
inline int randomInteger() {
  std::uniform_int_distribution<int> d;
  return d(randomEngine());
}
inline int randomInteger(int to) {
  ;
  std::uniform_int_distribution<int> d(0, to - 1);
  return d(randomEngine());
}
inline int randomInteger(int from, int to) {
  return from + randomInteger(to - from);
}
using namespace std;
class TaskF {
  int testNumber = 0;

 public:
  void solve(std::istream& in, std::ostream& out) {
    int n, k;
    in >> n >> k;
    vector<int> p(n);
    for (int i : range(n)) {
      in >> p[i];
      --p[i];
    }
    vector<int> l;
    vector<int> used(n);
    for (int i : range(n)) {
      if (!used[i]) {
        int len = 0;
        while (!used[i]) {
          ++len;
          used[i] = true;
          i = p[i];
        }
        l.push_back(len);
      }
    }
    if (can_get(l, k)) {
      out << k << ' ';
    } else {
      out << k + 1 << " ";
    }
    int max_mult = 0;
    for (int x : l) {
      max_mult += x / 2;
    }
    out << min(n, k + min(k, max_mult)) << "\n";
  }
  bool can_get(const vector<int>& l, int val) {
    using BS = bitset<1000100>;
    BS bs;
    bs.set(0);
    vector<int> len(1000100);
    for (int i : l) {
      len[i]++;
    }
    for (auto i : range(len.size())) {
      if (len[i] >= 3) {
        int pere = (len[i] - 1) / 2;
        assert(2 * i < len.size());
        len[2 * i] += pere;
        len[i] -= 2 * pere;
      }
    }
    for (auto i : range(len.size())) {
      for (int j : range(len[i])) {
        bs |= (bs << i);
      }
    }
    return bs.test(val);
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  TaskF solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  in.tie(nullptr);
  out << std::fixed;
  out.precision(20);
  solver.solve(in, out);
  return 0;
}
