#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int L,N; cin >> L >> N; vector W(N); for(auto &w : W) cin >> w; sort(W.begin(),W.end()); int answer = 0; for(auto &w : W){ if(w > L) break; L -= w; answer++; } cout << answer << endl; }