#include #include using namespace std; int main() { int L, N, w[10000], cnt=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; cnt++; } cout << cnt << endl; return 0; }