#include #include #include using namespace std; int main(void){ int l, n; cin >> l >> n; vector w(n); for(int i = 0; i < n; i++) { cin >> w[i]; } sort(w.begin(), w.end()); int i = 0, tmp = 0, res = 0; while(tmp + w[i] <= l){ res++; tmp += w[i]; i++; } cout << res << endl; return 0; }