#include <bits/stdc++.h>
int main() {
  auto n = int{};
  auto x = int{};
  std::cin >> n;
  std::cin >> x;
  auto a = std::vector<int>(n);
  for (auto& e : a) std::cin >> e;
  std::sort(a.begin(), a.end());
  auto i = int{};
  auto rem = x;
  for (auto const& e : a) {
    rem -= e;
    if (rem < 0) break;
    ++i;
  }
  std::cout << i << std::endl;
}
