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