#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long T;
  vector<int> A;
  cin >> N >> T;
  for (int x = 0; x < (N); x++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  long long ans = 0, sub = 0, i = 0;
  while (i < A.size() && sub < T) {
    sub += A.at(i++);
    ans++;
  }
  if (sub < T) {
    cout << N - 1 << endl;
  } else {
    if (i == 1) {
      cout << "0" << endl;
    } else {
      cout << ans << endl;
    }
  }
}
