{-# OPTIONS_GHC -Wall #-}

import Control.Exception
import Data.Array
import Data.List

readInt :: String -> Int
readInt = read

calcDp :: Int -> Int -> Array Int Int -> Array (Int,Int) Int
calcDp n m cs = assert (cs!0 == 1) dp
    where
        dp = listArray ((0,0),(m-1,n)) [f i j | i<-[0..m-1], j<-[0..n]]
        f _ 0 = 0
        f 0 j = j
        f i j
            | j >= c    = min (1+dp!(i,j-c)) (dp!(i-1,j))
            | otherwise = dp!(i-1,j)
            where
                c = cs!i

main :: IO ()
main = do
    [n,m] <- fmap (map readInt . words) getLine
    cs    <- fmap (map readInt . words) getLine
    let cs' = listArray (0,m-1) $ sort cs

    let dp  = calcDp n m cs'
    let ans = dp!(m-1,n)

    --print $ dp
    print $ ans

