#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, k; scanf("%d%d", &n, &k);
    vector <int> cnt(n + 1);
    for (int i = 0; i < n; ++i) {
        int x; scanf("%d", &x);
        cnt[x]++;
    }
    sort(cnt.begin(), cnt.end(), greater <int>());
    int sum = 0;
    for (int i = 0; i < k; ++i) sum += cnt[i];
    printf("%d\n", n - sum);
    return 0;
}