#include <bits/stdc++.h>
int main() {
  int n, x;
  std::cin >> n >> x;
  std::vector<int> a(n);
  for (auto &e : a) std::cin >> e;
  std::sort(a.begin(), a.end());
  struct Node {
    int n = 0;
    int x = 0;
  };
  std::vector<Node> dp(n + 1);
  int max = 0;
  dp[0].x = x;
  dp[n].n = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i - 1; j >= 0; j--) {
      if (dp[j].x >= a[i - 1]) {
        dp[i].x = dp[j].x - a[i - 1];
        dp[i].n = dp[j].n + 1;
        max = std::max(dp[i].n, max);
        break;
      }
    }
    if (dp[i].x == 0) {
      break;
    }
  }
  if (dp[n].x != 0) {
    max--;
  }
  std::cout << max << std::endl;
  return 0;
}
