// // main.cpp // yukicoder // // Created by Shuntaro Takahashi on 3/16/16. // Copyright © 2016 Kuphony. All rights reserved. // #include #include int main(int argc, const char * argv[]) { int l; std::cin >> l; int n; std::cin >> n; int w[l]; //配列の取得 for (int i = 0; i < n; i++) { std::cin >> w[i]; } std::sort(w,w+n); int result = 0; int tmp = 0; for (int i = 0; i < n; i++) { tmp += w[i]; if(tmp <= l){ result++; } } std::cout << result; std::cout << "\n"; return 0; }