import Prelude import Data.List (sort, inits) main :: IO () main = do l <- read <$> getLine _ <- getLine ws <- map read . words <$> getLine print $ calc l ws calc :: Int -> [Int] -> Int calc l ws = let ws' = sort ws in length $ takeWhile (l >) $ map sum $ drop 1 $ inits ws'