#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, -1, 0, 1};
template <class t, class u>
void chmax(t& a, u b) {
  if (a < b) a = b;
}
template <class t, class u>
void chmin(t& a, u b) {
  if (b < a) a = b;
}
long long fac(ll a) {
  long long ans = 1;
  while (a > 1) {
    ans *= a;
    ans %= 1000000007;
    a--;
  }
  return ans;
}
int main() {
  ll N;
  ll x;
  cin >> N >> x;
  vl a(N);
  for (ll i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort((a).begin(), (a).end());
  ll count = 0;
  ll b = 0;
  vl vec(N);
  for (ll i = 0; i < N; i++) {
    if (x - a.at(i) > 0) {
      vec.at(i) = a.at(i);
      x = x - a.at(i);
    } else if (x - a.at(i) == 0) {
      vec.at(i) = a.at(i);
      x = x - a.at(i);
    } else if ((x - a.at(i) < 0) && (x > 0)) {
      vec.at(i) = x;
      x = 0;
    } else if ((x - a.at(i) < 0) && (x == 0)) {
      vec.at(i) = 0;
    }
  }
  for (ll i = 0; i < N; i++) {
    if (a.at(i) == vec.at(i)) {
      count++;
    } else {
      b++;
    }
  }
  cout << count << endl;
}
