n, k = io.read("*n", "*n")
t = {}
for i = 1, n do
    a = io.read("*n")
    if(t[a] == nil) then t[a] = 1 else t[a] = t[a] + 1 end
end
tall = {}
for k, v in pairs(t) do
    table.insert(tall, v)
end
table.sort(tall)
tot = 0
remcount = #tall - k
for i = 1, remcount do
    tot = tot + tall[i]
end
print(tot)