n, k = io.read('n'), io.read('n')
bucket = {}
coll = {}

for i = 1, n do
    local a_i = io.read('n')
    bucket[a_i] = (bucket[a_i] or 0) + 1
end

for _, v in ipairs(bucket) do
    coll[#coll + 1] = v
end

table.sort(coll)

ans = n
for i = 1, math.min(k, #coll) do
    ans = ans - coll[#coll - i + 1]
end

print(ans)
