#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int32_t n, x;
  vector<int64_t> a;
  cin >> n >> x;
  for (int32_t i = 0; i < n; i++) {
    int64_t a_i;
    cin >> a_i;
    a.push_back(a_i);
  }
  sort(a.begin(), a.end());
  int sum(0);
  int n_s(0);
  for (auto a_i : a) {
    sum += a_i;
    if (sum <= x) {
      n_s++;
    } else {
      break;
    }
  }
  std::cout << n_s << std::endl;
  return 0;
}
