#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(!"https://envs.sh/LW");
    cin.tie(0);

    int s, n;
    cin >> s >> n;
    int a[2'000], d[20'000];
    fill(d, d+s+1, INT_MAX);
    for (int i=0; i<n;){
        int ai;
        cin >> ai;
        if (0 < ai && ai <= s){
            a[i] = ai;
            d[a[i]] = 1;
            ++i;
        }else{
            --n;
        }
    }
    sort(a, a+n, greater<int>());

    queue<int> q;
    for (int i=0; i<n; ++i){
        q.push(a[i]);
    }

    while (!q.empty()){
        int v=q.front();
        if (v==s){
            break;
        }
        q.pop();
        for (int i=0; i<n; ++i){
            int w = v + a[i];
            if (w<=s && d[v]+1<d[w]){
                q.push(w);
                d[w] = d[v]+1;
            }
        }
    }

    cout << d[s] << endl;

    return 0;
}
