// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll K, N;
  cin >> N >> K;

  vec<ll> A(N);
  REP(i, N) cin >> A[i];

  vec<ll> C(200'000, 0);
  REP(i, N) C[A[i]]++;
  C.erase(remove_if(ALL(C), [](ll c) { return c == 0; }), end(C));
  ll k = C.size();
  if (k <= K) {
    cout << 0 << endl;
    return 0;
  }
  sort(ALL(C));
  ll res = 0;
  for (const auto e : C) {
    res += e;
    if (--k <= K) {
      break;
    }
  }
  cout << res << endl;
  return 0;
}
