import Data.List main :: IO() main = do n <- readLn getLine xs <- sort.map read.words <$> getLine print $ solve n xs 0 solve n (x:xs) m | (n - x) < 0 = m | otherwise = solve (n - x) xs (m + 1)