#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using namespace std;
template <class t>
void vin(vector<t>& v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
int main() {
  ll N, x;
  cin >> N >> x;
  vector<ll> a(N);
  for (int(i) = (0); (i) < (int)(N); ++(i)) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
  }
  if (x > 0) ans--;
  if (ans < 0) ans = 0;
  cout << ans << endl;
}
