#include<bits/stdc++.h>
using namespace std;

vector<int> a;

int findAns(int s) {
    int ans = 0;
    for(int i = a.size()-1; i >= 0; i--) {
        while(s >= a[i]) {
            s -= a[i];
            ans++;
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int s, n, ans = 99999999;
    cin>>s>>n;
    for(int i = 0; i < n; i++) {
        int k;
        cin>>k;
        a.push_back(k);
    }

    sort(a.begin(), a.end());

    for(int i = n-1; i >= 0; i--) {
        ans = min(ans, findAns(s));
        a.pop_back();
    }


    cout<<ans<<endl;



    return 0;
}
