#include <bits/stdc++.h>
using namespace std;

int ketasum(int n){
  int sum = 0;
  while (n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  int count = 0;
  int rest = x;
  sort(a.begin(), a.end(), greater<int>())
  for (int i = 0; i < n; i++){
    rest = x -= a[i];
    if (rest - a[i] < 0) break;
    while(i<n-1) count++;
    if (i == n-1){
      if (rest > 0) break;
      else count++;
    }
  }

  cout << count << endl;
}
