#include using namespace std; int main() { int l, n; cin >> l >> n; vector w(n); for (int i = 0; i < n; i++) { cin >> w.at(i); } sort(w.begin(), w.end()); int count = 0; for (int i = 0; i < n; i++) { count += w.at(i); if (l < count) { cout << i << endl; return 0; } } cout << n << endl; return 0; }