#include #include #include using namespace std; #define rep(i,q) for(int i = 0; q > i; i++) int main(){ int L,N;cin >> L >> N; vector hi; int tmp; rep(i,N) cin >> tmp, hi.push_back(tmp); sort(hi.begin(),hi.end()); int sm = 0; int ret = 0; rep(i,hi.size()){ if(L >= sm){ ret++; sm += hi[i]; } else { break; } } cout << ret - 1 << endl; return 0; }