#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000];
bool cmp(int aa, int bb) { return aa > bb; }
int main() {
  int cnt(0), sum(0);
  cin >> n >> m;
  for (int i = 0; i != n; i++) scanf("%d", &a[i]);
  sort(a, a + n, cmp);
  do {
    sum += a[cnt++];
  } while (sum < m);
  printf("%d\n", cnt);
}
