#include #include #include #include #include #include using namespace std; #define diff(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x))) int main(void) { int l, n, ans = -1; cin >> l >> n; vector wide(n); for (int i = 0; i < n; i++) cin >> wide[i]; sort(wide.begin(), wide.end()); for (int i = 0; i < n; i++) { if (l <= 0) break; l -= wide[i]; ans++; } cout << ans << endl; return 0; }