#include<bits/stdc++.h>
using namespace std;
int a[2001],dp[20001],s,n;
int main(){
    cin>>s>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[a[i]]=1;
    }
    for(int i=2;i<=s;i++){
        for(int i1=0;i1<n;i1++){
            if(a[i1]>=i) continue;
            if(dp[i]==0) dp[i]=dp[i-a[i1]]+1;
            else dp[i]=min(dp[i],dp[i-a[i1]]+1);
        }
    }
    cout<<dp[s]<<"\n";
    return 0;
}
