import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;
import std.bigint;
import core.bitop;


void main() {
  auto s = readln.split.map!(to!int);
  auto N = s[0];
  auto M = s[1];
  auto C = readln.split.map!(to!int).array.sort();
  auto dp = new long[](N+1);
  foreach (i; 0..N+1) dp[i] = 10^^9+7;
  foreach (c; C) if(c <= N) dp[c] = 1;

  foreach (i; 1..N+1)
    foreach (c; C)
      if (i - c >= 0 && dp[i-c] > 0)
        dp[i] = min(dp[i-c]+1, dp[i]);

  dp[N].writeln;
}