#include <bits/stdc++.h>
using namespace std;
int n, m, a[1000];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  sort(a, a + n);
  reverse(a, a + n);
  int sum = 0, cnt = 0;
  if (m == 0) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    sum += a[i];
    cnt++;
    if (sum >= m) {
      cout << cnt;
      return 0;
    }
  }
}
