#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a;
  int sum = 0;
  for (size_t i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
    sum += tmp;
  }
  sort(a.begin(), a.end());
  auto it = a.size() - 1;
  int n_a = a.size();
  if (sum >= x) {
    while (sum >= x) {
      if (sum == x) {
        cout << n_a << endl;
        return 0;
      }
      sum -= a[it];
      it--;
      n_a--;
    }
    it++;
    n_a++;
    while (it != a.size()) {
      if ((sum + a[it]) == x) {
        cout << n_a << endl;
        return 0;
      }
      it++;
    }
    cout << max(n_a - 1, 0) << endl;
  } else {
    cout << n_a - 1 << endl;
  }
  return 0;
}
