#include<bits/stdc++.h>
using namespace std;
int n, a[2001], dp[20001];
int f(int s){
    if(dp[s] != 0)return dp[s];
    if(s < 0)return INT_MIN;
    if(s == 0)return 0;
    int ans = INT_MAX;
    for(int i = n - 1; i >= 0; i--){
        if(a[i] > s)continue;
        ans = min(ans, f(s - a[i]));
    }
    //cout << s << " " << ans + 1 << endl;
    dp[s] = ans + 1;
    return ans + 1;
}
int main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int s; cin >> s >> n;
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a, a + n);
    cout << f(s) << endl;

    return 0;
}
