#include <bits/stdc++.h>
int main() {
  int N;
  int x;
  int kids[105];
  int order[105];
  int all = 0;
  int flag = 0;
  std::cin >> N >> x;
  for (int i = 0; i < N; i++) {
    std::cin >> kids[i];
    all += kids[i];
    order[i] = kids[i];
    if (i != 0) {
      for (int j = i; j > 0; j--) {
        if (order[j] > order[j - 1]) {
          order[j] = order[j - 1];
          order[j - 1] = kids[i];
        }
      }
    }
  }
  if (all == x) {
    std::cout << N << '\n';
    flag = 1;
  } else if (all < x) {
    std::cout << N - 1 << '\n';
    flag = 1;
  } else {
    for (int i = 0; i < N; i++) {
      if (x >= all - order[i]) {
        std::cout << N - i - 1 << '\n';
        flag = 1;
      } else {
        all -= order[i];
      }
    }
  }
  if (!flag) std::cout << 0 << '\n';
  return 0;
}
