#include #include int l, n; int w[10001]; int main(){ std::cin >> l >> n; for (int i = 0; i < n; ++i)std::cin >> w[i]; std::sort(w, w + n); int cnt = 0; for (int i = 0; i < n; ++i){ if (l < w[i])break; else l -= w[i], ++cnt; } std::cout << cnt << std::endl; return 0; }