import Data.List

toInt :: String -> Int
toInt = read :: String -> Int

getAns :: [Int] -> Int -> Int
getAns a k = sum . take n $ sort l
  where
    l = map length . group $ sort a
    n = length l - k

main = do
  [n, k] <- map toInt . words <$> getLine
  a <- map toInt . words <$> getLine
  print $ getAns a k
