import Data.List solve l (w:ws) | ws == [] = 0 | 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