#include <bits/stdc++.h>
using namespace std;
template <typename tp>
void read(tp& dig) {
  char ch = getchar();
  dig = 0;
  long long flag = 0;
  while (!isdigit(ch)) {
    if (ch == '-') flag = 1;
    ch = getchar();
  }
  while (isdigit(ch)) dig = dig * 10 + ch - '0', ch = getchar();
  if (flag) dig = -dig;
}
long long n, m, a[110];
int main() {
  read(n);
  read(m);
  for (long long i = 1; i <= n; ++i) read(a[i]);
  sort(a + 1, a + n + 1);
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    m -= a[i];
    if (m >= 0)
      ans = i;
    else
      break;
  }
  if (m) --ans;
  printf("%lld\n", ans);
  return 0;
}
