#include #include #include int main() { 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 ans = 0; int width_sum = 0; for (auto &w: W) { width_sum += w; if (width_sum > L) { break; }; ans++; } std::cout << ans << std::endl; }