#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
int a[100];
int main() {
  int n, x;
  cin >> n >> x;
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  sort(a, a + n);
  int ret = 0;
  for (int i = (0); i < (n); ++i) {
    if (x >= a[i]) ret++;
    x -= a[i];
  }
  if (x > 0) ret--;
  cout << ret << endl;
  return 0;
}
