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

int ans[50004];

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

    scanf("%d %d", &n, &m);
    c=calloc(m, sizeof(int));

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

    memset(ans, 200000, sizeof(ans));
    ans[0]=0;

    for(i=0;i<m;i++){
        for(j=0;j+c[i]<=n;j++){
            x=ans[j]+1;
            if(x<ans[j+c[i]])ans[j+c[i]]=x;
        }
    }

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