#include <bits/stdc++.h>
#pragma GCC optimize(3)
const int MN = 10000 + 5;
using namespace std;
template <typename T>
inline T& IN(T& in) {
  in = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) in = in * 10 + c - '0', c = getchar();
  return in *= f;
}
int n, ans, s;
int a[MN];
void input() {
  IN(n);
  IN(s);
  for (int i = 1; i <= n; ++i) IN(a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    if (a[i] <= s) {
      ans++, s -= a[i];
    }
  }
  if (s) ans--;
  ans = max(ans, 0);
  printf("%d\n", ans);
}
int main() {
  input();
  return 0;
}
