#include #include using namespace std; int main() { int n,m; cin >> n >> m; int c[n],sum = 0; for(int i = 0; i < n; i++){ cin >> c[i]; sum += c[i]; } sort(c,c+n); int ans; if(m >= sum){ cout << n << endl; return 0; }else{ for(ans = 0; m > 0; ans++) m -= c[ans]; cout << (m == 0 ? ans : ans-1) << endl; return 0; } }