let change n m d =
  let dp = Array.make_matrix (m + 1) (n + 1) max_int in
  for i = 0 to m do dp.(i).(0) <- 0 done;
  for i = 1 to m do
    for j = 1 to n do
      dp.(i).(j) <-
        if j >= d.(i-1) && dp.(i).(j - d.(i-1)) + 1 < dp.(i-1).(j)
        then dp.(i).(j - d.(i-1)) + 1
        else dp.(i-1).(j);
    done
  done;
  dp.(m).(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"