local n, k = io.read("*n", "*n")
local t = {}
for i = 1, n do
  local a = io.read("*n")
  if t[a] then t[a] = t[a] + 1 else t[a] = 1 end
end
local tm = {}
for k, v in pairs(t) do
  table.insert(tm, v)
end
table.sort(tm, function(x, y) return x > y end)
if #tm <= k then print(0)
else
  local c = 0
  for i = k + 1, #tm do
    c = c + tm[i]
  end
  print(c)
end
