#include <bits/stdc++.h>
int main() {
  size_t N;
  intmax_t x;
  scanf("%zu %jd", &N, &x);
  std::vector<intmax_t> a(N);
  for (size_t i = 0; i < N; ++i) scanf("%jd", &a[i]);
  std::sort(a.begin(), a.end());
  int res = 0;
  for (size_t i = 0; i < N; ++i) {
    if (a[i] <= x) {
      x -= a[i];
      ++res;
    }
  }
  printf("%d\n", res);
}
