#include <bits/stdc++.h>
using namespace std;
const int N = 123;
int n, k, a[N], ans;
unordered_map<long long, int> dp;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) {
    unordered_map<long long, int> b = dp;
    for (unordered_map<long long, int>::iterator it = dp.begin();
         it != dp.end(); ++it)
      if (it->first + a[i] <= k)
        b[(it->first) + a[i]] = max(b[(it->first) + a[i]], it->second + 1);
    dp = b;
    dp[a[i]] = max(dp[a[i]], 1);
    b.clear();
  }
  for (unordered_map<long long, int>::iterator it = dp.begin(); it != dp.end();
       ++it) {
    if (it->first > k) break;
    if ((it->second == n && it->first == k) || it->second != n)
      ans = max(ans, it->second);
    else
      ans = max(ans, it->second - 1);
  }
  cout << ans;
  return 0;
}
