#include int main() { int L, N, W[10000] = {0}, i, j, k = 0, tmp, x = 0; scanf("%d %d", &L, &N); for (i = 0; i < N; i++) { scanf("%d", &W[i]); } for (i = 0; i < N; i++) { for (j = i+1; j < N; j++) { if (W[i] > W[j] && j != N) { tmp = W[i]; W[i] = W[j]; W[j] = tmp; } } } for (i = 0; i < N; i++) { if (x == L || x < L) { x += W[i]; k++; } if (x == L) { printf("k=%d\n", k); } else if (x > L) { printf("k=%d\n", k-1); } } return 0; }