#include<iostream>
#include<algorithm>
using namespace std;
int s,n;
const int MAXN = 2e3+5;
const int MAXS = 2e4+5;
int a[MAXN],dp[MAXS];
int rec(int cost){
    if(dp[cost]!=1e9) return dp[cost];
    for(int i=0;i<n;i++){
        if(cost-a[i]>=0) dp[cost]=min(dp[cost],rec(cost-a[i])+1);
    }
    return dp[cost];
}
bool cmp(int A,int B){
    return A>B;
}
int main(){
    fill(dp,dp+MAXS,1e9);
    cin>>s>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[a[i]]=1;
    }
    sort(a,a+n,cmp);
    cout<<rec(s)<<"\n";
    return 0;
}
