#include using namespace std; int main(){ int L,N; vector w; int in; cin >> L >> N; while(cin >> in) w.push_back(in); sort(w.begin(), w.end()); int i=0; while(L>0) { L-=w[i]; if(L>=0) i++; } cout << i << endl; return 0; }