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