#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 sum = 0, count = 0; for (vector::size_type i = 0; sum < L; i++){ sum += W[i]; count++; } cout << count-1 << endl; }