#include<iostream>
using namespace std;
const int MAXN = 2*1e4+7;
int dp[MAXN];
int a[MAXN];
int main () {
    int S;
    cin>>S;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int currsum=0;currsum<=S;currsum++){
        //cout<<"za "<<currsum<<"\n";
        if(currsum>0 and dp[currsum]==0){
            continue;
        }
        for(int i=0;i<n;i++){
            if(dp[currsum+a[i]]==0) dp[currsum+a[i]]=dp[currsum]+1;
            else dp[currsum+a[i]]=min(dp[currsum+a[i]],dp[currsum]+1);
            //cout<<"    veche dp["<<currsum+a[i]<<"]= "<<dp[currsum+a[i]]<<"\n";
        }
    }
    cout<<dp[S]<<"\n";
}
