#include <bits/stdc++.h>
using namespace std;
int main() {
  int 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());
  int ans = 0;
  for (long long(i) = (0); (i) < (n); ++i) {
    if (x >= v[i]) ans++;
    x -= v[i];
  }
  if (x > 0) ans--;
  cout << ans << endl;
  return 0;
}
