#include <bits/stdc++.h>
using namespace std;
template <class T>
bool equal(T x, T y) {
  return x == y;
}
template <>
bool equal(const char* x, const char* y) {
  return std::strcmp(x, y);
}
template <class Iterator, class Compare>
void selection_sort(Iterator first, Iterator last, Compare comp) {
  for (Iterator p = first; p != last; ++p) {
    Iterator min_position = p;
    for (Iterator q = p; q != last; ++q) {
      if (comp(*q, *min_position)) min_position = q;
    }
    auto tmp = *min_position;
    *min_position = *p;
    *p = tmp;
  }
}
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int getsum(int n) {
  int res = 0;
  while (n) {
    res += n % 10;
    n /= 10;
  }
  return res;
}
int A[110];
int main() {
  long N, x;
  cin >> N >> x;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  sort(A, A + N);
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    if (x >= A[i]) {
      x -= A[i];
      ans++;
    } else {
      break;
    }
    if (x == 0) break;
  }
  if (x != 0)
    cout << max(0, ans - 1) << endl;
  else
    cout << ans << endl;
  return 0;
}
