#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> a;
int ans;
int main() {
  cin >> n >> m;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = n - 1; i >= 0; i--) {
    m -= a[i];
    ans++;
    if (m <= 0) break;
  }
  cout << ans;
}
