#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  ll x, n;
  cin >> n >> x;
  vector<ll> a(n);
  ll sum = 0;
  ll min = pow(10, 9);
  for (ll i = 0; i < n; i++) {
    cin >> a.at(i);
    sum += a.at(i);
    if (a.at(i) < min) min = a.at(i);
  }
  sort(a.begin(), a.end());
  if (x > sum)
    cout << n - 1;
  else if (x < min)
    cout << 0;
  else {
    ll cnt = 0;
    ll acc = 0;
    while (acc < x) {
      acc += a.at(cnt);
      cnt++;
    }
    cout << cnt;
  }
}
