#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();
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char const *argv[]) {
  int N, x, ans = 0;
  cin >> N, cin >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for (int j = 0; j < N; j++) {
    if (a.at(j) <= x && x > 0) {
      x -= a.at(j);
      ans++;
    }
  }
  if (x > 0 && ans > 1) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
