#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k;
    cin>>n>>k;
    vector<int> ball(n,0);
    int count=0;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        ball[tmp-1]++;
    }
    sort(ball.begin(),ball.end());
    for(int i=0;i<n-k;i++){
        count+=ball[i];
    }
    cout<<count<<endl;
}
