#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 (int i = 0; i < (int)(n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (a[i] <= x) {
      ans++;
      x -= a[i];
    }
  }
  if (ans > 0 && x > 0) ans--;
  cout << ans << endl;
  return 0;
}
