#include using namespace std; int main() { int l, n; cin >> l; cin >> n; int box[n]; int sum = 0; int count = 0; for(int i = 0; i < n; i++) { cin >> box[i]; } while (sum < l) { int min = 10001; int j; for(int i = 0; i < n; i++) { if (box[i] != -1 && box[i] < min) { min = box[i]; j = i; } } sum += min; count++; box[j] = -1; } if (sum == l) { count++; } cout << count - 1 ; }