#include int main(void){ int l,n,i,j,tmp; int wi[10000]; scanf("%d%d",&l,&n); for(i=0;i=i;j--){ if(wi[j] < wi[j-1]){ tmp = wi[j]; wi[j] = wi[j-1]; wi[j-1] = tmp; } } } i=0; while(1){ l-=wi[i]; if(l<0) break; i++; if(i == n) break; } printf("%d",i); return 0; }