#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int minimales[20000];
vector<int> chisla;
int main(){
int n,s;
cin>>s>>n;
for(int a=0;a<=s;a++){
    minimales[a]=200001;
}
minimales[0]=0;
for(int a=0;a<n;a++){

int b;
cin>>b;
chisla.push_back(b);
minimales[chisla[a]]=1;}
sort(chisla.begin(),chisla.end());
for(int a=2;a<=s;a++){
    for(int b=0;chisla[b]<=a && b<chisla.size();b++){
        minimales[a]=min(minimales[a],(minimales[a-chisla[b]]+1));
    }
}
cout<<minimales[s];
return 0;
}
