#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUF_SIZE 10200

int comp(const void* a, const void* b) {
  return *(int*)a - *(int*)b;
}

int main(void) {
  char line[BUF_SIZE];
  FILE *fp = stdin;

  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int num, quant;
  sscanf(line, "%d %d", &num, &quant);

  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int *arr = malloc(sizeof(int)*num);
  int i;
  char* tmpbuf = line;
  for(i = 0; i < num; i++) {
    char *tmp = strtok(tmpbuf, " ");
    arr[i] = strtol(tmp, NULL, 10);
    tmpbuf = NULL;
  }
  qsort(arr, num, sizeof(int), comp);

  int sum = 0;
  for(i = 0; i < num; i++) {
    sum += arr[i];
    if(sum >= quant) break;
  }

  printf("%d\n", i);
  return 0;
}