#include using namespace std; void sort(int* a) { } int main() { int l, n; cin >> l >> n; int w[n]; int i; for (i = 0; i < n; i++) cin >> w[i]; sort(w); // 小さい順(昇順) for (i = 0; l >= 0; i++) l -= w[i]; if (l = 0) cout << i << endl; else cout << i-1 << endl; return 0; }