#include using namespace std; int main(void){ int L, N, i, *W; cin >> L >> N; W = (int*)calloc(N, sizeof(int)); for(i=0; i> *(W+i); qsort(W, N, sizeof(*W), [](const void *a, const void *b){return *(int*)a - *(int*)b;}); i = 0; while(1){ if(L-*(W+i) < 0 || i > N-1) break; L -= *(W+i++); } cout << i << endl; free(W); return 0; }