#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-5;
const double PI = acos(-1.0);
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  sort((a).begin(), (a).end());
  int ans = 0;
  for (int i = (0); i < (n); ++i) {
    if (a[i] <= x) {
      ans++;
      x -= a[i];
    } else {
      break;
    }
  }
  if (x != 0) ans--;
  cout << (ans) << endl;
  ;
}
