#include <bits/stdc++.h>
using namespace std;
template <class T>
using vv = vector<vector<T> >;
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "\t";
  }
  s << "\n";
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
  }
  return s;
}
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  vector<int> a(n);
  for (int(i) = (0); (i) < (n); ++(i)) {
    scanf("%d", &a[i]);
  }
  sort(begin(a), end(a));
  int ans = 0;
  for (int(i) = (0); (i) < (n); ++(i)) {
    if (x >= a[i]) {
      x -= a[i];
      ans += 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
