import Control.Applicative qsort :: (Ord a) => [a] -> [a] qsort [] = [] qsort (x:xs) = qsort leeq ++ [x] ++ qsort gt where (leeq, gt) = go x xs [] [] go _ [] a b = (a, b) go p (y:ys) a b = if y <= p then go p ys (y:a) b else go p ys a (y:b) solver :: Int -> [Int] -> Int solver len sor = go len sor 0 (-1) where go _ [] _ n = n go l (x:xs) s n | l <= s = n | otherwise = go l xs (s + x) (n + 1) main :: IO () main = do lenstr <- getLine let len = (read lenstr :: Int) n <- getLine widths <- words <$> getLine let sorted = qsort $ (map read widths :: [Int]) putStrLn $ show $ solver len sorted