#include <stdio.h>

int min(int a, int b){
  if(a>b){
    return b;
  }else{
    return a;
  }
}


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

  scanf("%d %d",&n,&m);
  for(i = 1; i <= m ; i++){
    scanf("%d",&c[i]);
  }
  for(i = 0 ; i <= n ; i++){
    dp[i] = 99999;
  }
  dp[0] = 0;
  for(i = 1; i <= m ; i++){
    for(j = 0 ; j+c[i] <= n ; j++){
      dp[j+c[i]] = min(dp[j]+1,dp[j+c[i]]);
    }
  }
  printf("%d\n",dp[n]);
      
  return 0;
}

