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