#include<bits/stdc++.h>
#define MAXN 20010
using namespace std;
int a[2010], s, n;
int f(int indx, int sum){
    if(sum == s){
        return 0;
    }
    if(sum > s or indx == n){
        return MAXN;
    }
    int z = (s - sum)/a[indx] + 1, ans = 0, otg = MAXN;
    //cout << a[indx] << " " << sum << " " << z << "\n\n";
    for(int i = 0; i < z; i++){
        sum += (i * a[indx]);
        ans = i;
        //cout << i << " " << sum << " " << ans << "\n";
        ans += f(indx + 1, sum);
        otg = min(ans, otg);
        sum -= (i*a[indx]);
        ans = 0;
    }
    return otg;
}
int main(){
    cin >> s >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    /*for(int i = 0; i < n; i++){
        cout << a[i] << " ";
    }*/
    cout << "\n" << f(0, 0);
    return 0;
}
