import Data.List main = do l <- readLn getLine w <- map read . words <$> getLine print . length . filter (<=l) . tail $ scanl (+) 0 $ sort w