import Control.Applicative ((<$>)) import Data.List (sort) main :: IO () main = do l <- readLn :: IO Int n <- readLn :: IO Int ws <- map read <$> words <$> getLine :: IO [Int] print $ length $ takeWhile (<=l) $ scanl1 (+) $ sort ws