#include <bits/stdc++.h>
using namespace std;
int n, xx, x, ans, say, top, a[1000005];
int main() {
  scanf("%d %d", &n, &xx);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    top += a[i];
  }
  if (top == xx) {
    printf("%d\n", n);
    return 0;
  }
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    x = xx;
    say = 0;
    for (int j = 1; j <= n; j++)
      if (j != i and x >= a[j]) {
        say++;
        x -= a[j];
      }
    ans = max(ans, say);
  }
  printf("%d\n", ans);
  return 0;
}
