#include <bits/stdc++.h>
int main() {
  int i, n, *a, t, j, flag;
  long m;
  scanf("%d", &n);
  scanf("%ld", &m);
  a = (int*)calloc(n, sizeof(int));
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++)
    for (j = 0; j < n - i - 1; j++)
      if (a[j + 1] > a[j]) {
        t = a[j + 1];
        a[j + 1] = a[j];
        a[j] = t;
      }
  flag = 1;
  for (i = 0; i < n && flag; i++) {
    m = m - a[i];
    if (m <= 0) flag = 0;
  }
  printf("%d", i);
  return 0;
}
