#include <bits/stdc++.h>
using namespace std;
class ACandyDistributionAgain {
 public:
  void solve(istream& cin, ostream& cout) {
    long long int n, x;
    cin >> n >> x;
    vector<long long int> a;
    for (int i = 0; i < n; i++) {
      int tp;
      cin >> tp;
      a.push_back(tp);
    }
    sort(a.begin(), a.end());
    int i;
    for (i = 0; i < n; i++) {
      if (x < a[i]) break;
      x -= a[i];
    }
    if (x > 0 && i != 0) i--;
    cout << i << '\n';
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(NULL);
  ACandyDistributionAgain solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
