#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> vec(n);
  for (auto &v : vec) cin >> v;
  sort(vec.begin(), vec.end());
  bool flag = false;
  ll cnt = 0;
  for (ll i = 0; i < n; ++i) {
    if (i != 0) vec[i] = vec[i - 1] + vec[i];
    cnt += vec[i] <= x;
    if (vec[i] == x) flag = true;
  }
  if (flag)
    cout << cnt << endl;
  else
    cout << cnt - 1 << endl;
}
