#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007LL;
ll ADD(ll x, ll y) { return (x + y) % MOD; }
ll SUB(ll x, ll y) { return (x - y + MOD) % MOD; }
ll MUL(ll x, ll y) { return x * y % MOD; }
ll POW(ll x, ll e) {
  ll v = 1;
  for (; e; x = MUL(x, x), e >>= 1)
    if (e & 1) v = MUL(v, x);
  return v;
}
ll DIV(ll x, ll y) { return MUL(x, POW(y, MOD - 2)); }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int i = 0, ans = 0;
  while (true) {
    if (x - a[i] < 0 || i == n) break;
    x -= a[i];
    i++;
    ans++;
  }
  cout << (x == 0 ? ans : max(ans - 1, 0)) << endl;
  return 0;
}
