#include <bits/stdc++.h>
using namespace std;
struct Graph {
  vector<vector<int> > edges;
  vector<int> dst;
  int size;
  Graph(int n) {
    size = n;
    edges.resize(n);
    for (int i = 0; i < n; i++) {
      edges[i].reserve(n);
    }
    dst.resize(n);
  }
  void bfs(vector<int> s) {
    fill(dst.begin(), dst.end(), -1);
    queue<int> q;
    for (int i = 0; i < s.size(); i++) {
      q.push(s[i]);
      dst[s[i]] = 1;
    }
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int i = 0; i < edges[v].size(); i++) {
        int new_dst = dst[v] + 1;
        if (dst[edges[v][i]] == -1) {
          dst[edges[v][i]] = new_dst;
          q.push(edges[v][i]);
        }
      }
    }
    return;
  }
  void add_edge(int u, int v) { edges[u].push_back(v); }
};
vector<int> string_split(string s, const char delimiter) {
  size_t start = 0;
  size_t end = s.find_first_of(delimiter);
  vector<int> output;
  while (end <= string::npos) {
    output.emplace_back(stoi(s.substr(start, end - start)));
    if (end == string::npos) break;
    start = end + 1;
    end = s.find_first_of(delimiter, start);
  }
  return output;
}
int main() {
  int n, k, a;
  cin >> n >> k;
  vector<bool> coke(1001, 0);
  string s1;
  getline(cin, s1);
  getline(cin, s1);
  vector<int> arr = string_split(s1, ' ');
  while (k--) {
    a = arr[k];
    coke[a] = 1;
  }
  if (coke[n]) {
    cout << "1\n";
    return 0;
  }
  Graph g(2001);
  vector<int> s;
  for (int i = 0; i < 1001; i++) {
    if (coke[i]) {
      int d = n - i;
      s.push_back(d + 1000);
      if (d > 0) {
        for (int j = d; j < 2001; j++) {
          g.add_edge(j - d, j);
        }
      } else {
        d = -d;
        for (int j = d; j < 2001; j++) {
          g.add_edge(j, j - d);
        }
      }
    }
  }
  g.bfs(s);
  cout << g.dst[1000] << endl;
  return 0;
}
