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