#include<bits/stdc++.h>
using namespace std;

int s,n,a[2005],p[2005],mig;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>s>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<=s;i++){
        mig=1000000000;
        for(int j=0;j<n;j++){
            if(i-a[j]>=0){
                mig=min(p[i-a[j]],mig);
            }
            p[i]=mig+1;
        }
        //cout<<i<<" "<<p[i]<<endl;
        //cout<<p[i]<<endl;
    }
    cout<<p[s]<<endl;

    return 0;
}
