#include #include #include using namespace std; #define REP(_i,_n) for(int _i=0;_i<_n;_i++) int main() { int l,n; int i = 0; cin >> l >> n; vector w(n); REP(j, n) cin >> w[j]; sort(w.begin(), w.end()); while (1) { if (l - w[i] < 0) break; l -= w[i]; i++; } cout << i << endl; return 0; }