#include<bits/stdc++.h>
using namespace std;
int arr[2000];
int main(){
    int n,s;
    int biggest_ost=0;
    int biggest_index=0;
    int optional=INT_MAX;
    cin>>s>>n;
    int br=0;
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    while(s!=0){
        for(int i=0;i<n;i++){
            if(arr[i]==s){
                br++;
                br=min(optional,br);
                cout<<br<<endl;
                return 0;
            }
            if(s%arr[i]==0){
                int temp=br+s/arr[i];
                optional=min(temp,optional);
            }
            if(biggest_ost<=s%arr[i] && arr[i]<s){
                biggest_index=i;
                biggest_ost=s%arr[i];
            }
        }
        //cout<<s<<" "<<arr[biggest_index]<<endl;
        s-=arr[biggest_index];
        br++;
        biggest_ost=0;
        biggest_index=0;
    }
}
