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

#define INF 100000

int getmin(int n, int m, int *c);

int main(void){
  int i, ans, n, m, *c;

  scanf("%d%d", &n, &m);
  c = (int *)malloc(sizeof(int) * m);
  for(i = 0; i < m; i++){
    scanf("%d", &c[i]);
  }
  ans = getmin(n, m, c);
  printf("%d\n", ans);
  free(c);
  return 0;
}

int getmin(int n, int m, int *c){
  int i, j, k;
  int *min = (int *)malloc(sizeof(int) * (n+1));

  for(i = 0; i <= n; i++){
    k = INF;
    for(j = 0; j < m; j++){
      if(i - c[j] >= 0){
	if(min[i-c[j]] < k){
	  k = min[i-c[j]];
	}
      }
    }
    if(k == INF){
      min[i] = 0;
    }else{
      min[i] = k+1;
    }
  }
  k = min[n];
  free(min);
  return k;
}