#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll inf = ll(1e18);
using ll1d = vector<ll>;
using ll2d = vector<ll1d>;
using ll3d = vector<ll2d>;
void solve(istream &ccin = cin, ostream &ccout = cout) {
  ll n, x;
  ccin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < (int)(n); ++i) ccin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  ll cnt = 0;
  bool isSSS = false;
  for (int i = 0; i < (int)(n); ++i) {
    cnt += a[i];
    ++ans;
    if (cnt > x) {
      --ans;
      break;
    } else if (x == cnt) {
      break;
    }
  }
  if (accumulate(a.begin(), a.end(), 0) < x) --ans;
  ccout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
