#include #include int main(){ int N, M; scanf("%d %d", &N, &M); int cs[100]; for(int i=1;i<=N;i++){ scanf("%d", cs+i); } std::sort(cs+1, cs+1+N); int res = 0; for(int i=1;i<=N;i++){ if(cs[i] >= M){ if(cs[i] == M){res = i;} else{res = i-1;} break; }else{ M -= cs[i]; } } printf("%d\n", res); }