#include #define inf 10001 int L,N; int W[10000]; int min(int W[],int N){ int i; int t = 0; int min = W[0]; for(i = 1;i < N;i++){ if(W[i] < min){ min = W[i]; t = i; } } W[t] = inf; return min; } int main(){ int i,j; scanf(" %d",&L); scanf(" %d",&N); for(i = 0;i < N;i++){ scanf(" %d",&W[i]); } int sum = 0; int count = 0; for(i = 0;i < N;i++){ sum += min(W,N); if(sum >= L){ break; } count++; } printf("%d\n",count); return 0; }