#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string, int>;
int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  ll total = 0;
  ;
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
    total += a[i];
  }
  ll ans;
  if (total < x)
    ans = n - 1;
  else if (total == x)
    ans = n;
  else {
    sort(a.begin(), a.end());
    ;
    for (ll i = 0; i < n; ++i) {
      if (x <= 0) {
        ans = i;
        break;
      }
      x -= a[i];
    }
  }
  cout << ans << endl;
  return 0;
}
