#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(void) {
  ll N, x;
  ll count = 0;
  vector<ll> A;
  bool flag = false, flagB;
  cin >> N >> x;
  A.resize(N);
  for (ll i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  for (ll i = 0; x > 0 && i >= 0; !flag && i++) {
    if (x < A[i]) {
      flag = true;
      flagB = true;
      i--;
    } else {
      if (flag && flagB) {
        count--;
        flagB = false;
      } else {
        count++;
      }
      x -= A[i];
    }
  }
  cout << count << endl;
  return 0;
}
