#include using namespace std; const int INF = 1e9; int dp[100010]; int main() { cin.tie(0); ios::sync_with_stdio(false); int c, n; cin >> c >> n; vector a(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 1; i <= c; i++) dp[i] = INF; for (int i = 0; i < n; i++) { for (int j = a[i]; j <= c; j++) { dp[j] = min(dp[j], dp[j - a[i]] + 1); } } cout << (dp[c] == INF ? -1 : dp[c]) << endl; return 0; }