#include using namespace std; using ll = long long; int sum[1 << 17], dp[1 << 17]; int main() { cin.tie(0); ios::sync_with_stdio(false); int T, n; cin >> T >> n; vector t(n); for (int i = 0; i < n; i++) { cin >> t[i]; } for (int i = 1; i < (1 << n); i++) { for (int j = 0; j < n; j++) { if (i & (1 << j)) { sum[i] += t[j]; } } dp[i] = n; } for (int i = 1; i < (1 << n); i++) { for (int j = i; j > 0; j = (j - 1) & i) { if (sum[j] > T) continue; dp[i] = min(dp[i], dp[i ^ j] + 1); } } cout << dp[(1 << n) - 1] << endl; return 0; }