#include using namespace std; #define REP(i,N) for(i=0;i P; typedef struct{ int first; int second; int third; }T; //昇順 bool comp_Se(T& l, T& r){ return l.second < r.second; } int main(void){ int L,N; cin >> L >> N; int i,x,num=0; priority_queue, greater > W; REP(i,N){ cin >> x; W.push(x); } while(W.size()){ if(L>W.top()){ L-=W.top(); W.pop(); num++; }else break; } cout << num << endl; return 0; }