#include<bits/stdc++.h>
using namespace std;
int n,s,a[2004];
int dp[2004][20004];
int solve(int it,int sum){
    if(sum<0||it<0){
        return 20004;
    }
    if(sum==0){
        return 0;
    }
    if(dp[it][sum]!=0){
        return dp[it][sum];
    }
    return dp[it][sum]=min(solve(it-1,sum),solve(it,sum-a[it])+1);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("test.txt","r",stdin);
bool ans=false;
memset(dp,0,sizeof(dp));
cin>>s>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
    if(a[i]==s){
        cout<<"1";
        ans=true;
        break;
    }
}
int otg=20001;
if(!ans){
    for(int i=0;i<n;i++){
        otg=min(otg,solve(i,s));
    }
    cout<<otg;
}
return 0;
}
