#include using namespace std; int main() { 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 count = 0; for (int i = 0;i < n;i++) { l -= w[i]; count++; if (l < 0) { count--; break; } } cout << count << endl; return 0; }