#include <bits/stdc++.h>
using namespace std;
void solve(long long N, long long x, std::vector<long long> a) {
  long long cnt = x;
  sort(a.begin(), a.end());
  for (long long i = 0; i < N; ++i) {
    if (i == 0) {
      if (a[i] > x) {
        cout << 0 << endl;
        return;
      }
    }
    cnt -= a[i];
    if (cnt <= 0) {
      cout << i + 1 << endl;
      return;
    }
  }
  cout << N - 1 << endl;
  return;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long x;
  scanf("%lld", &x);
  std::vector<long long> a(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
  }
  solve(N, x, std::move(a));
  return 0;
}
