#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

void run (void) {
  i32 n, m;
  scanf ("%" SCNi32 "%" SCNi32, &n, &m);
  i32 *dp = (i32 *) calloc (n + 1, sizeof (i32));
  for (i32 i = 1; i <= n; ++i) {
    dp[i] = i;
  }
  while (m--) {
    i32 c;
    scanf ("%" SCNi32, &c);
    for (i32 i = c; i <= n; ++i) {
      if (dp[i] > dp[i - c] + 1) {
	dp[i] = dp[i - c] + 1;
      }
    }
  }
  printf ("%" PRIi32 "\n", dp[n]);
}

int main (void) {
  run ();
  return 0;
}

