#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, x;
  cin >> n >> x;
  vector<int> child(n);
  for (int i = 0; i < (int)n; i++) {
    cin >> child.at(i);
  }
  sort(child.begin(), child.end());
  int ans = 0;
  for (int i = 0; i < (int)n; i++) {
    if (child.at(i) <= x) {
      ans++;
      x = x - child.at(i);
    }
  }
  if (x >= child.at(0)) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
