#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max()/32*15+208; int main() { int t, n; cin >> t >> n; vector v(n); for (auto &&i : v) scanf("%d", &i); vector a(1 << n); for (int i = 1; i < (1 << n); ++i) { int s = 0; for (int j = 0; j < n; ++j) { if(i & (1 << j)) s += v[j]; } a[i] = (s <= t ? 1 : INF); } vector dp(1 << n); for (int i = 1; i < (1 << n); ++i) { dp[i] = a[i]; for (int j = (i-1)&i; j != i; j = (j-1)&i) { dp[i] = min(dp[i], dp[i^j]+dp[j]); } } cout << dp.back() << "\n"; return 0; }