#include <bits/stdc++.h>
int N, res;
unsigned int x, a[100];
int solve() {
  int idx = 0;
  std::sort(a, a + N);
  while (x > 0 && idx < N) {
    if (a[idx] <= x) {
      x -= a[idx];
      ++res;
    }
    ++idx;
  }
  if (x > 0 && res > 0) --res;
  return res;
}
int main() {
  std::cin >> N >> x;
  for (int i = 0; i < N; ++i) std::cin >> a[i];
  std::cout << solve() << std::endl;
  return 0;
}
