let change n m d =
  let dp = Array.make (n + 1) max_int in
  dp.(0) <- 0;
  for i = 0 to m - 1 do
    for x = 0 to n - d.(i) do
      let v = x + d.(i) in
      if dp.(x) + 1 < dp.(v) then dp.(v) <- dp.(x) + 1;
    done
  done;
  dp.(n)

let () =
  let (n, m) = Scanf.scanf "%d %d " (fun n m -> (n, m)) in
  let d = Array.init m (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  change n m d |> Printf.printf "%d\n"