import qualified Data.Map as Map
import Data.List
 
freq :: (Foldable f, Ord a) => f a -> Map.Map a Int
freq xs = foldl' inc Map.empty xs
  where inc = \m x -> Map.insert x (Map.findWithDefault 0 x m + 1) m
 
main = do
  [n, k] <- map read . words <$> getLine :: IO [Int]
  a <- map read . words <$> getLine :: IO [Int]
  print $ n - (sum . take k . sortBy (flip compare) . Map.elems . freq) a