#include #include int main() { int L; std::cin >> L; int N; std::cin >> N; std::priority_queue, std::greater > pq; int tmp; while(std::cin >> tmp) { pq.push(tmp); } int sum = 0 , n = 0; while(sum <= L) { sum += pq.top(); pq.pop(); n++; } n--; std::cout << n << std::endl; return 0; }