import Control.Applicative ((<$>))
import Data.Array (listArray, (!))
import Data.List (sort, foldl')

main :: IO ()
main = do
    [n,m] <- getInts
    cs <- getInts
    print $ solve n m $ sort cs

getInts :: IO [Int]
getInts = map read . words <$> getLine



solve :: Int -> Int -> [Int] -> Int
solve n _ (_:cs) = table ! n
    where
        table = foldl' build initial cs
        initial = listArray (0,n) [0..n]
        build pre c = res
            where
                res = listArray (0,n)
                        [x | y <- [0..n]
                           , let x | c > y = pre ! y
                                   | otherwise = let res1 = (pre ! y) 
                                                     res2 = (1 + (res ! (y-c)))
                                                  in res1 `seq` res2 `seq` min res1 res2]