#include #include #include int main(int argc, char* argv[]) { int l, n; std::cin >> l >> n; std::vector w(n); for (int i = 0; i < n; ++i) { std::cin >> w[i]; } std::sort(w.begin(), w.end()); int block_num = 0; int block_width = 0; for (int i = 0; i < n; ++i) { if (block_width + w[i] > l) { break; } block_width += w[i]; ++block_num; } std::cout << block_num << std::endl; return 0; }