#include "dpcoin.h"
#include <stdio.h>
#include <stdlib.h>
#define INFINITY 99999;

int main(void) {
  int i,j,d,n,m,*C,*T;
  
  if (scanf("%d %d",&n,&m) < 2) exit(1);
  C = malloc(m*sizeof(int));
  for (i=0;i<m;i++) {
    if (scanf("%d",&d) < 1) exit(1);
    C[i] = d;
  }
  
  T = malloc((n+1)*sizeof(int));
  for (i=0;i<=n;i++) T[i] = INFINITY;
  T[0] = 0;
  for (i=0;i<m;i++) {
    for (j=C[i];j<=n;j++) {
      if (T[j] > T[j-C[i]]+1) T[j] = T[j-C[i]]+1;
    }
  }
  
  printf("%d\n",T[n]);
  
  return 0;
}