#include #include #include using namespace std; int main() { int l, n; cin >> l >> n; vector w(n); for (int &wi: w) cin >> wi; sort(w.rbegin(), w.rend()); int sum = 0; while (sum + w.back() <= l) sum += w.back(), w.pop_back(); cout << n - w.size() << endl; return 0; }