#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> children(n);
  for (int i = 0; i < n; ++i) cin >> children.at(i);
  sort(children.begin(), children.end());
  int j = 0;
  int sum = 0;
  for (int i = 0; i < n; ++i) sum += children[i];
  if (sum < x) {
    cout << n - 1 << endl;
    return 0;
  } else if (sum == x) {
    cout << n << endl;
    return 0;
  }
  while (x > 0) {
    x -= children[j];
    ++j;
  }
  cout << j << endl;
  return 0;
}
