#include <stdio.h>
#define MAXN 50050

int main()
{
    int n, m, i,j;
    int dp[MAXN];
    for(i = 1; i<=n;i++){
        dp[i] = 0;
    }
    scanf("%d %d",&n,&m);
    int d[m+1];
    for(i = 1; i<=m; i++){
        scanf("%d",&d[i]);
        dp[d[i]] = 1;
    }
    for(i = 2; i<=n;i++){
        int min = MAXN;
        if(dp[i]==0){//cal
            for(j=1;j<=m;j++){
                if(d[j]<i){
                    if(dp[i-d[j]]<min) min = dp[i-d[j]];
                }
            }
            dp[i] = min+1;
        }
        
        
    }
    
    
    printf("%d",dp[n]);

    return 0;
}