#include #include #include #include using namespace std; int main(){ int L, N; cin >> L >> N; vector W(N); for (int i = 0; i < N; i++){ cin >> W[i]; } sort(W.begin(), W.end()); double SAM=0.0; int i = 0; while (SAM <= L){ SAM += W[i]; i++; } cout << i-1 << endl; }