n,k=io.read("*n","*n","*l")
a={}
for i=1,n do
    x=io.read("*n")
    if not a[x] then
        a[x]=1
    else
        a[x]=a[x]+1
    end
end

b={}
for _,j in pairs(a) do
    table.insert(b,j)
end
table.sort(b)

ball=0
if #b-k>0 then
    for i=1,#b-k do
        ball=ball+b[i]
    end
end
print(ball)