#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
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 count = 0;
  while (x >= 0) {
    x -= a[count];
    ++count;
  }
  cout << min(count - 1, n) << endl;
  return 0;
}
