#include <bits/stdc++.h>
using namespace std;
int br ,minbr,S,N;
vector<int>v;
int suma =0;
void rekursiq(int suma , int br){
   // br++;
    if(suma==S){
           //cout<<br<<endl;
        if(minbr>br){
            minbr=br;
        }
        br = 0;
        suma=0;
        return;
    }
    if(suma>S){
            br= 0;
            suma=0;
        return;
    }
    for(int i=0;i<N;i++){
      //  cout<<suma<<endl;
   //  cout<<"v[i] = "<<v[i]<<" suma = "<<suma<<" br = "<<br<<endl;
        rekursiq(suma+v[i], br+1);
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>S>>N;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        v.push_back(a);

    }
    //sort(v.begin(),v.end());
    br=S;
    minbr=S;
    rekursiq(0 , 0);
    cout<<minbr<<endl;

}
