#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-w[i]>0) L-=w[i++]; cout << i << endl; return 0; }