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