#include <bits/stdc++.h>
int main(void) {
  int a, b, c, e, m, x, y, p, d, q;
  c = 0;
  x = 0;
  y = 0;
  int N[1000] = {};
  scanf("%d", &a);
  scanf("%d", &b);
  while (c < a) {
    scanf("%d", &N[c]);
    c++;
  }
  for (p = 0; p < a; p++) {
    for (q = p + 1; q < a; q++) {
      if (N[p] > N[q]) {
        d = N[p];
        N[p] = N[q];
        N[q] = d;
      }
    }
  }
  for (m = 0; m < a; m++) {
    if (b >= x + N[m]) {
      x = x + N[m];
      y++;
    }
  }
  if (b > x && y > 0) {
    y--;
  }
  printf("%d", y);
}
