#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> ar(n);
  for (int i = 0; i < n; ++i) cin >> ar[i];
  sort(ar.begin(), ar.end(), greater<int>());
  int sum = 0, cnt;
  for (int i = 0; i < n; ++i) {
    if (sum < m) {
      sum += ar[i];
      cnt = i;
    } else
      break;
  }
  cout << cnt + 1;
  return 0;
}
