#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int main() {
  int n, m, c = 0, s = 0;
  cin >> n >> m;
  int *x = new int[n];
  for (int i = 0; i < n; i++) cin >> x[i];
  sort(x, x + n);
  for (int i = n - 1; i >= 0; i--) {
    if (c < m) {
      c += x[i];
      s++;
    } else
      break;
  }
  cout << s;
  return 0;
}
