#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, sum = 0, cnt = 0;
  cin >> N >> x;
  int a[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + N);
  for (int i = 0; i < N; i++) {
    if (sum < x) {
      cout << N - i - 1 << endl;
      break;
    } else if (sum == x) {
      cout << N - i << endl;
      break;
    } else
      sum -= a[N - i - 1];
    if (i == N - 1) cout << "0" << endl;
  }
}
