#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; } } } tmp=0;i=0; while(1){ tmp+=wi[i]; if(tmp>l) break; i++; } printf("%d\n",i); return 0; }