#include <stdio.h>

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

int main(void)
{
  int n, m;
  int c[20];
  int dp[50010];
  int i, j;

  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++){
    scanf("%d", &c[i]);
  }

  dp[0] = 0;
  for (i = 1; i <= n; i++){
    dp[i] = 1 << 28;
  }

  for (i = 0; i < m; i++){
    for (j = 0; j + c[i] <= n; j++){
      dp[j + c[i]] = min(dp[j + c[i]], dp[j] + 1);
    }
  }

  printf("%d\n", dp[n]);
}