#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  long long x, ans = 0;
  std::vector<long long> vec(n);
  std::cin >> x;
  for (int i = 0; i < n; ++i) {
    std::cin >> vec[i];
  }
  std::sort(vec.begin(), vec.end());
  for (int i = 0; i < n; ++i) {
    if (x <= 0 || x < vec[i]) {
      std::cout << ans << std::endl;
      return 0;
    }
    x -= vec[i];
    ++ans;
  }
  std::cout << ans << std::endl;
  return 0;
}
