import           Data.List


main :: IO ()
main = do
    [n ,k] <- getInts
    as <- sortBy (\a b -> compare (length b)  $ length a)
          . group . sort <$> getInts
    print $ n - solve k as

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve k = sum . map length . take k
