#include #include #include #include using namespace std; int main() { priority_queue, greater > minpq; int L,N; int a; cin >> L >> N; for (int i = 0; i < N; i++) { cin >> a; minpq.push(a); } int ans = 0,ima; for (int i = 0; i < N; i++) { int ima = minpq.top(); minpq.pop(); L -= ima; if(L <= 0) { break; } ++ans; } cout << ans << endl; }