#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, total = 0;
  cin >> n >> x;
  vector<int> hp;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    hp.push_back(x);
  }
  sort(hp.begin(), hp.end());
  for (int i = 0; i < n; i++) {
    total = total + hp[i];
  }
  if (total < x)
    cout << n - 1;
  else if (total == x) {
    cout << n;
  } else {
    int i = 0;
    while (x < total) {
      total = total - hp[n - 1 - i];
      i++;
    }
    cout << n - i;
  }
}
