#include "bits/stdc++.h" using namespace std; int main() { int L, N, W[10000], count = 0; cin >> L >> N; for (int i = 0; i < N; i++) { cin >> W[i]; } sort(W, W + N); for (int i = 0; i < N; i++) { L -= W[i]; if (L <= 0) break; count++; } cout << count << endl; }