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