#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
int main(void)
{
  int i, j, n, m;
  int *c, *t;
  scanf("%d %d", &n, &m);
  c = (int*)malloc(sizeof(int) * m);
  t = (int*)malloc(sizeof(int) * (n + 1));
  for (i = 0; i < m; i++) scanf("%d", &c[i]);
  for (i = 0; i <= n; i++) t[i] = INT_MAX;
  t[0] = 0;
  for (i = 0; i < m; i++) {
    for (j = 0; j + c[i] <= n; j++) {
      if (t[j+c[i]] > t[j] + 1) t[j+c[i]] = t[j] + 1;
    }
  }
  printf("%d\n", t[n]);
  free(c);
  free(t);
}
