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