#include <bits/stdc++.h>
struct Node {
 public:
  Node() = default;
  Node(const int& sum, const int& child) : sum(sum), child(child) {}
  int sum = 0;
  int child = 0;
};
void printVec(const std::vector<Node>& vec) {
  for (const auto& v : vec) {
    std::cout << "(" << v.sum << " " << v.child << "), ";
  }
  std::cout << std::endl;
}
void printNode(const Node& v) {
  std::cout << "(" << v.sum << " " << v.child << "), ";
}
int main() {
  int N, x;
  std::cin >> N >> x;
  std::vector<int> a;
  for (int i = 0; i < N; i++) {
    int a_;
    std::cin >> a_;
    a.emplace_back(a_);
  }
  int ans = 0;
  std::vector<Node> new_nodes{Node(0, 0)};
  for (int i = 0; i < N; i++) {
    std::vector<Node> nodes = new_nodes;
    new_nodes.clear();
    for (const auto& node : nodes) {
      new_nodes.emplace_back(Node(node.sum, node.child));
      if (node.child > ans) {
        ans = node.child;
      }
      if (node.sum + a.at(i) < x and i != N - 1) {
        new_nodes.emplace_back(Node(node.sum + a.at(i), node.child + 1));
        if (node.child + 1 > ans) {
          ans = node.child + 1;
        }
      } else if (node.sum + a.at(i) == x) {
        if (node.child + 1 > ans) {
          ans = node.child + 1;
        }
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
