#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX(x,y) (((x)>(y))?(x):(y))
#define MIN(x,y) (((x)<(y))?(x):(y))
#define N 10000000
int n,m;
int c[21];
int score[50001];//dpテーブル
void coin(){
    int i,j;
    for(i=0;i<n;i++){
        score[i] = N;
    }//初期化
    score[0] = 0;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            int h = i - c[j];
            if (h>=0){
                score[i] = MIN(score[i],score[h]+1);
            }
        }
    }
    printf("%d\n",score[n-1]);
}
int main(void){
    int i;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&c[i]);
    }
    coin();
    return 0;
}