#include <bits/stdc++.h>
using namespace std;
struct initon {
  initon() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  };
};
bool is_prime(const unsigned n) {
  switch (n) {
    case 0:
    case 1:
      return false;
    case 2:
    case 3:
      return true;
  }
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (unsigned i = 5; i * i <= n; i += 6) {
    if (n % i == 0) return false;
    if (n % (i + 2) == 0) return false;
  }
  return true;
}
long long k = 0, n = 0, m = 0, l = 0, r = 0, a = 0, b = 0, c = 0, d = 0, e = 0,
          ans = 0, ans2 = 0, x = 0, y = 0;
string s, t, S;
signed main() {
  cin >> n >> x;
  vector<long long> A(n);
  for (long long i = 0; i < (long long)(n); i++) scanf("%lld", &A[i]);
  ;
  sort(A.begin(), A.end());
  while (1) {
    a++;
    if (x - A[a] >= 0)
      x -= A[a];
    else
      break;
  }
  cout << a << endl;
}
