#include using namespace std; int main() { int t, n; cin >> t >> n; vector v(n); for (int i = 0; i < n; i++) cin >> v[i]; vector dp((1 << n), 1e9); dp[0] = 0; for (int bit = 1; bit < (1 << n); bit++) { int total = 0; for (int i = 0; i < n; i++) { if (bit & (1 << i)) { total += v[i]; } } if (total <= t) dp[bit] = 1; } int cnt = 0; for (int bit = 1; bit < (1 << n); bit++) { for (int i = bit; i > 0; i = (i-1) & bit) { dp[bit] = min(dp[bit], dp[i] + dp[bit^i]); cnt++; } } cout << dp[(1 << n) - 1] << endl; }