#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define maxn 200010
using namespace std;
int n,k,a[maxn];
bool cmp(int c,int b)
{
	return c>b;
}
int main()
{
	scanf("%d%d",&n,&k);
	int v;
	for(int i=1;i<=n;++i)
	scanf("%d",&v),a[v]++;
	sort(a+1,a+maxn-10+1,cmp);
	int ans=0;
	for(int i=1;i<=k;++i)
	ans+=a[i];
	cout<<n-ans;
	return 0;
}