#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());
  while (sum >= x) {
    if (sum == x) {
      cout << n << endl;
      return 0;
    }
    int tmp = a.back();
    a.pop_back();
    sum -= tmp;
    n--;
  }
  cout << max(n - 1, 0) << endl;
  return 0;
}
