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