#include <stdio.h>
#define MAX 50005

int min(int x, int y)
{
  return x < y ? x : y;
}

int main(void)
{
  int n, m;
  int c[20];
  int t[20][MAX];
  
  scanf("%d%d", &n, &m);
  
  for (int i = 0; i < m; i++) {
    scanf("%d", &c[i]);
    t[i][0] = 0;
  }
  
  for (int i = 1; i <= n; i++)
    t[0][i] = i;
  
  for (int i = 1; i < m; i++)
    for (int j = 0; j <= n; j++)
      t[i][j] = j < c[i] ? t[i-1][j] : min(t[i-1][j], t[i][j-c[i]]+1);
  
  printf("%d\n", t[m-1][n]);
  
  return 0;
}
