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