#include <bits/stdc++.h>

using namespace std;

queue<int> q;
unordered_map<int, int> d;

int dist(int n)
{
    auto search = d.find(n);
    if (search != d.end()) {
        return search->second;
    } else {
        return INT_MAX;
    }
}

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

    int s, n;
    cin >> s >> n;
    int a[2'000];
    for (int i=0; i<n; ++i){
        cin >> a[i];
        q.push(a[i]);
        d[a[i]] = 1;
    }

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

    cout << dist(s) << endl;

    return 0;
}
