#include <bits/stdc++.h>
using namespace std;
int a[52025];
bool cmp(int x, int y) { return x > y; }
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + n + 1, cmp);
  for (int i = 1; i <= n; ++i) {
    m -= a[i];
    if (m <= 0) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
