text: #include <algorithm>
  #include <iostream>
  #include <iterator>
  #include <vector>
  
  int main() {
      int n;
      long k;
      std::cin >> n >> k;
      (void)n;
      std::vector<long> prices{
          std::istream_iterator<long>(std::cin),
          std::istream_iterator<long>()
      };
      std::sort(prices.begin(), prices.end());
      long total = 0;
      int count = 0;
      for (auto it = prices.begin(); it != prices.end() && total < k; ++it) {
          total += *it;
          count += total < k;
      }
      std::cout << count << "\n";
  }
  
  