#include using namespace std; #define int long long const int MOD = 1e9+7; const int INF = 1LL << 60; int dp[101][101010]; signed 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]; } fill(dp[0],dp[100]+101010,INF); dp[0][0] = 0; for(int i = 0; i < N; i++){ for(int j = 0; j <= C; j++){ if(j-a[i] >= 0){ dp[i+1][j] = min(dp[i][j],dp[i+1][j-a[i]]+1); } else dp[i+1][j] = dp[i][j]; } } if(dp[N][C] == INF) cout << -1 << endl; else cout << dp[N][C] << endl; return 0; }