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