#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int cnt = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (x - a[i] >= 0) {
      if (i == 0 && a[i] == x) {
        cnt++;
        x -= a[i];
      } else if (i != 0) {
        cnt++;
        x -= a[i];
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
