#include #include using namespace std; int main() { int l, n, j; int *w; int sum = 0; cin >> l >> n; w = new int[n]; for (int i = 0; i < n; i++) { cin >> w[i]; } sort(w, w + n); for (j = 0; sum + w[j] < l; j++) { sum += w[j]; } cout << j << endl; }