#include using namespace std; int main() { int box, block; cin >> box; cin >> block; int b[block]; for(int i = 0; i < block; i++){ cin >> b[i]; } int total = 0; int output = 0; sort(b, b + block); while(total <= box){ total += b[output]; output += 1; } cout << output-1 << endl; return 0; }