import Data.Array
read_int = read :: String -> Int
main = do
  nm_in <- (return . words) =<< getLine
  let n:m:[] = map read_int nm_in
  c_in <- (return . words) =<< getLine
  let c = map read_int c_in
  print ((dp n c)!!n)
  
dp n c = elems memo
  where
    memo = listArray (0,n) [f i| i<-[0..n]]
    f 0 = 0
    f x = 1 + minimum ([50000] ++ (map (memo!) [x-ci|ci<-c,ci<=x]))
