#include #include #include using namespace std; int main() { int L, N; cin >> L; cin >> N; vector W; int temp; for (int i = 0; i < N; i++){ cin >> temp; W.push_back(temp); } sort(W.begin(), W.end()); int count = 0; for (vector::size_type i = 0; i < W.size(); i++){ if (L > 0){ L -= W[i]; count++; } else break; } cout << count << endl; }