#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 = 0; while (box_width >= v[count]) { box_width -= v[count]; count++; } std::cout << count << std::endl; return 0; }