#include using namespace std; int main() { const int INF = 1e9; int dp[100000 + 5]; int c, n; cin >> c >> n; for (int i = 0; i <= c; i++) { dp[i] = INF; } dp[0] = 0; for (int i = 0; i < n; i++) { int a; cin >> a; for (int j = 0; j <= c; j++) { if (dp[j] == INF || j + a > c) { continue; } dp[j + a] = min(dp[j + a], dp[j] + 1); } } cout << (dp[c] == INF ? -1 : dp[c]) << endl; return 0; }