#include #include #include #include int main(){ int L,N; std::vector W{}; std::cin >> L >> N; W.reserve(N); std::copy_n(std::istream_iterator(std::cin),N,std::back_inserter(W)); std::sort(W.begin(),W.end()); auto how_many = 0; for(auto w : W){ if(L >= w){ L -= w; ++how_many; } } std::cout << how_many << std::endl; return 0; }