N=io.read("n")
K=io.read("n")
A={}
t={}
for i=1,N do 
  A[i]=io.read("n")
  t[A[i]]=(t[A[i]] or 0)+1
end
local count=0
number={}
for i,v in pairs(t) do
  count=count+1
  number[count]=v
end
table.sort(number)
local res=0
for i=1,number-K do
  res=res+number[i]
end
print(res)
