#include using namespace std; int main() { int L, N, tmp, sum; cin >> L >> N; int W[N]; for(int i = 0; i < sizeof(W)/sizeof(W[0]); i++){ cin >> W[i]; } for(int i = 0; i < N; i++){ for(int j = i + 1; j < N; j++){ if(W[i] > W[j]){ tmp = W[i]; W[i] = W[j]; W[j] = tmp; } } } int i; for(i = 0; L - sum < 0; i++){ sum += W[i]; } cout << i << endl; return 0; }