#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  int distributing;
  vector<int> distrubiton;
  if (N <= 100) {
    for (int count(0); count < N; ++count) {
      cin >> distributing;
      distrubiton.push_back(distributing);
    }
  }
  sort(distrubiton.begin(), distrubiton.end());
  int sum(0), counting(0), total = x, alot(0);
  for (auto each : distrubiton) {
    if (total >= each) {
      if (each == *(distrubiton.end() - 1) && total > each) {
        if (total > pow(10, 9)) {
          while (total > pow(10, 9)) {
            --counting;
            total -= pow(10, 9);
          }
          --counting;
        }
        break;
      }
      ++counting;
      total -= each;
    }
  }
  if (counting > 0)
    cout << counting;
  else
    cout << 0;
  return 0;
}
