import Data.List solve _ [] = 0 solve l (w:ws) | l - w >= 0 = 1 + solve (l - w) ws | otherwise = solve (l - w) ws main = do l <- readLn getLine ws <- sort . map (read :: String -> Int) . words <$> getLine print $ solve l ws