#include #include template using MinHeap = std::priority_queue, std::greater>; void solve() { int n, m; std::cin >> n >> m; MinHeap heap; while (n--) { int c; std::cin >> c; heap.push(c); } int ans = 0; while (m > 0) { int h = heap.top(); heap.pop(); if (h <= m) { ++ans; m -= h; } else { break; } } std::cout << ans << std::endl; } int main() { std::cin.tie(nullptr); std::cout.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }