#include typedef long long i64; using std::cout; using std::endl; using std::cin; int main(){ int T, n; cin >> T >> n; std::vector t(n); for(int i = 0; i < n; i++) cin >> t[i]; std::vector vec; std::vector li(1 << n, false); for(int i = 1; i < (1 << n); i++) { int tmp = 0; for(int j = 0; j < n; j++) if((i >> j) & 1) tmp += t[j]; if(tmp > T) continue; vec.push_back(i); li[i] = true; } while(true) { std::vector nv; std::vector tmp(vec.size(), true); for(int i = 0; i < vec.size(); i++) { for(int j = 0; j < vec.size(); j++) { if(!tmp[j]) continue; for(int k = 0; k < n; k++) { if(!((vec[i] >> k) & 1) and (vec[j] >> k) & 1) { tmp[i] = false; break; } } if(!tmp[i]) break; } if(tmp[i]) nv.push_back(vec[i]); } vec.swap(nv); if(vec.size() == nv.size()) break; } std::vector dp(1 << n, 1 << 30); dp[0] = 0; for(int i = 0; i < (1 << n); i++) { for(auto bit : vec) { if(i & bit) continue; dp[i | bit] = std::min(dp[i | bit], dp[i] + 1); } } cout << dp[(1 << n) - 1] << endl; return 0; }