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