import Data.List (sort) import Control.Applicative ((<$>)) empty = 100001 :: Int pickCandy :: [Int] -> [Int] pickCandy cs | c' > 0 = c' : cr | otherwise = cr ++ [empty] where (c : cr) = cs c' = c - 1 pickCandies :: Int -> [Int] -> [Int] pickCandies 0 cs = cs pickCandies m cs = pickCandies (m - 1) $ pickCandy cs main :: IO () main = do (_ : m : _) <- map read . words <$> getLine print . length . filter (== empty) . pickCandies m . sort . map read . words =<< getLine