#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  unordered_map<long long, long long> mp;
  mp[0] = 0;
  long long lef[x], rig[x];
  long long ctr = 0;
  for (auto it = a.begin(); it != a.end(); ++it) {
    for (auto mi = mp.begin(); mi != mp.end(); ++mi) {
      auto j = mi->first + *it;
      if (j > x) continue;
      lef[ctr] = j;
      rig[ctr] = mi->second + 1;
      ++ctr;
    }
    for (auto i = 0; i < ctr; ++i) {
      mp[lef[i]] = max(mp[lef[i]], rig[i]);
    }
    ctr = 0;
  }
  auto sl = max_element(mp.begin(), mp.end(),
                        [](const pair<int, int>& p1, const pair<int, int>& p2) {
                          return p1.second < p2.second;
                        });
  auto ret = sl->second;
  if ((sl->first != x) and (sl->second - a.size() == 0)) ret -= 1;
  cout << ret << endl;
  return 0;
}
