#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const bool test = true;
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
const long long INF = (long long)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (long long)1e9 + 7;
const double eps = 1e-10;
long long sgn(const long double& r) { return (r > eps) - (r < -eps); }
long long sgn(const long double& a, const long double& b) { return sgn(a - b); }
const long long MAX = (long long)2e5 + 5;
vector<string> split(const string& str, char sep) {
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (getline(ss, buffer, sep)) {
    v.push_back(buffer);
  }
  return v;
}
template <typename T>
vector<T> sorted(vector<T>& a) {
  auto res = a;
  sort(res.begin(), res.end());
  return res;
}
template <typename T>
void vec_print(vector<T>& a) {
  for (auto& v : a) cerr << v << " ";
  cerr << endl;
}
template <class InputIterator>
long long sum(InputIterator begin, InputIterator end) {
  return accumulate(begin, end, 0ll);
}
template <typename T>
T gcd(T a, T b) {
  T c;
  while (a != 0) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;
}
long long pow(long long a, long long b) {
  long long res = 1;
  for (long long i = 0; i < (long long)(b); ++i) res *= a;
  return res;
}
class Solver {
 public:
  long long H, W;
  bool grid_ng(long long y, long long x) {
    return y < 0 || y >= H || x < 0 || x >= W;
  }
  long long N, x;
  vector<long long> a;
  void solve() {
    cin >> N >> x;
    a.resize(N);
    for (long long i = 0; i < (long long)(N); ++i) cin >> a[i];
    sort(a.begin(), a.end());
    long long cur = x;
    long long cnt = 0;
    for (auto& v : a) {
      if (cur < v) {
        break;
      }
      cur -= v;
      cnt += 1;
    }
    if (cur != x && cur != 0) cnt -= 1;
    cout << cnt << endl;
  }
};
signed main() {
  srand(time(NULL));
  cout << fixed << setprecision(20);
  auto ptr = new Solver();
  ptr->solve();
  delete ptr;
  return 0;
}
