#include int main(void){ int l,n,w[10001],swap; scanf("%d",&l); scanf("%d",&n); for(int i = 0; i < n; i++)scanf("%d",&w[i]); for(int i = 0; i < n; i++){ int min = 10001,minpoint; for(int j = i; j < n; j++){ if(min > w[j]){ min = w[j]; minpoint = j; } } swap = w[i]; w[i] = w[minpoint]; w[minpoint] = swap; } int sum = 0,count; for(int i = 0; i < n; i++){ if(sum >= l)break; sum += w[i]; count++; } printf("%d\n",count - 1); }