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