#include #include #include int main() { int box_width, toys; std::cin >> box_width >> toys; std::vector v(toys); for (int i = 0; i < toys; i++) { std::cin >> v[i]; } std::sort(v.begin(), v.end()); int count; for (count = 0; count < toys; count++) { if (box_width < v[count])break; box_width -= v[count]; } std::cout << count << std::endl; return 0; }