#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main() {
  ll N, x;
  cin >> N >> x;
  vector<ll> an(N);
  for (auto&& a : an) {
    cin >> a;
  }
  sort(an.begin(), an.end());
  ll rst = x;
  ll ans = 0;
  for (ll i = 0; i < an.size(); ++i) {
    if (rst - an[i] >= 0) {
      rst -= an[i];
      ans++;
    }
  }
  if (rst > 0) ans = std::max<ll>(0, ans - 1);
  cout << ans << endl;
  return 0;
}
