#include using namespace std; int dp[1 << 17]; int sum[1 << 17]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int T, t, n; vector v; cin >> T; cin >> n; for (int i = 0; i < n; i++) { cin >> t; v.push_back(t); } for (int i = 0; i < (1 << n); i++) { int temp = 0; for (int j = 0; j < n; j++) { if ((i & (1 << j))) { temp += v[j]; } } sum[i] = temp; } fill(dp, dp + (1 << 17), 1e9); dp[0] = 0; for (int i = 0; i < (1 << n); i++) { if (sum[i] <= T) { dp[i] = min(dp[i], 1); } for (int j = i & i; j > 0; j = (j - 1) & i) { int a = i ^ j; int b = j; //cout << a << ' ' << b << ' ' << i << '\n'; if (sum[b] <= T) { dp[i] = min(dp[i], dp[a] + 1); } } //res = max(res,dp[(1<