#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, a, c = 0, q;
  cin >> n >> m;
  vector<long long int> v;
  while (n--) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  while (m > 0) {
    c++;
    q = v.size();
    m -= v[q - 1];
    v.pop_back();
  }
  cout << c;
  return 0;
}
