#include <iostream>
using namespace std;
const int INF = 1e9;
int ans[20000];
int main () {
    int s, n;
    cin >> s >> n;
    for (int i = 1; i <= s; i++) {
        ans[i] = -1;
    }
    for (int i = 1; i <= s; i++) {
        ans[i] = INF;
    }
    ans[0] = 0;
    for (int i = 1; i <= n; i++) {
        int v;
        cin >> v;
        ans[v] = 1;
    }

    for (int i = 1; i <= s; i++) {
        if (ans[i] == -1) {
            ans[i] = i;
        }
        for (int j = 1; j <= i && j + i <= s; j++) {
            ans[i + j] = min(ans[i + j], ans[i] + ans[j]);
        }
    }
    cout << ans[s];
    return 0;
}

