#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, x;
  cin >> N >> x;
  vector<ll> a(N);
  for (int i = 0; i < N; ++i) cin >> a[i];
  sort(begin(a), end(a), greater<ll>());
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (a[i] <= x) {
      ++ans;
      x -= a[i];
    }
  }
  if (x) ans = max(ans - 1, 0);
  cout << ans << endl;
  return 0;
}
