#include #include #include using namespace std; int main(void) { int Box, num, i = 0; cin >> Box >> num; vector wide(num); for (; i < num; i++) cin >> wide[i]; sort(wide.begin(), wide.end()); i = 0; while (Box >= wide[i]) { Box -= wide[i]; i++; } cout << i << "\n"; return 0; }