#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, y = -1, sum = 0;
  cin >> n >> x;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  if (x < v.at(0))
    cout << 0 << endl;
  else {
    for (int i = 0; i < n; i++) {
      sum += v.at(i);
      if (sum >= x) {
        cout << i + 1 << endl;
        y = 0;
        break;
      }
    }
    if (y == -1) cout << n << endl;
  }
}
