#include <bits/stdc++.h>
using namespace std;
int main() {
  multiset<int, greater<int> > A;
  int N, M, TE;
  cin >> N >> M;
  for (int i = 1; i <= N; ++i) {
    cin >> TE;
    A.insert(TE);
  }
  int ans = 0;
  multiset<int>::iterator i;
  for (i = A.begin(); i != A.end() && M > 0; ++i) M -= *i, ++ans;
  cout << ans << '\n';
  return 0;
}
