#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)3e5 + 10;
const int inf = (int)1e9 + 5;
const long long llinf = (long long)1e18 + 5;
int a[maxn];
long long m, n, k, l, t, i, s, j, kol;
int main() {
  cin >> n;
  cin >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  k = 0;
  s = 0;
  for (i = n - 1; i >= 0; i--) {
    k = k + a[i];
    s++;
    if (k >= m) {
      break;
    }
  }
  cout << s << endl;
  return 0;
}
