local read = io.read
local N, K = read("n", "n")

local number_of_types = {}
local have_types_s = {}
for i = 1, N do
	local readed = read("n")
	if have_types_s[readed] then
		local index = have_types_s[readed]
		number_of_types[index] = number_of_types[index] + 1
	else
		local new_index = #number_of_types + 1
		have_types_s[readed] = new_index
		number_of_types[new_index] = 1
	end
end

table.sort(number_of_types)

local out = 0
for i = 1, #number_of_types - K do
	out = out + number_of_types[i]
end

print(out)
