import Data.List
import Debug.Trace

main = do
  [n,k] <- map read . words <$> getLine :: IO [Int]
  as <- map read . words <$> getLine :: IO [Int]
  print $ solve as k

solve as k =
  ans
  where
    as' = group $ sort as
    len = length as'
    as'' = sortOn length as'
    check as@(a:_) k' acc
      | k'<=k = acc
      | otherwise =
--        traceShow (as,k',acc) $
        check (tail as) (k'-1) (acc + length a) 
    ans = check as'' len 0
