#include #include #include using namespace std; int main() { int n, m, ans = 0; priority_queue,greater> cs; cin >> n >> m; for (int i = 0; i < n; i++) { int c; cin >> c; cs.push(c); } while (m > 0 && !cs.empty()) { int c = cs.top(); if (c <= m) { m -= c; ans++; cs.pop(); } else break; } cout << ans << endl; return 0; }