#include <bits/stdc++.h>
int com(void const *a, void const *b) {
  int val1 = *(int *)a;
  int val2 = *(int *)b;
  return (val1 - val2);
}
int main() {
  int sweet, children[1000], i, j, temp, count, k, total, happy = 0, sum, small;
  scanf("%d%d", &total, &sweet);
  for (i = 0; i < total; i++) {
    scanf("%d", &children[i]);
  }
  qsort(children, total, sizeof(int), com);
  for (k = 0; k < total; k++) {
    if (children[k] <= sweet) {
      sweet -= children[k];
      happy++;
    }
  }
  printf("%d", happy);
  return 0;
}
