#include <bits/stdc++.h>
using namespace std;
long long rec(long long a[], long long x, long long ind,
              map<long long, long long> temp[]) {
  if (temp[ind][x] != 0) return temp[ind][x];
  if (ind == 0) {
    if (x == a[0])
      temp[ind][x] = 1;
    else
      temp[ind][x] = 0;
  } else if (x >= a[ind])
    temp[ind][x] =
        max(rec(a, x - a[ind], ind - 1, temp) + 1, rec(a, x, ind - 1, temp));
  else
    temp[ind][x] = rec(a, x, ind - 1, temp);
  return temp[ind][x];
}
int main() {
  long long n, x;
  cin >> n >> x;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  map<long long, long long> temp[n + 1];
  cout << rec(a, x, n - 1, temp) << endl;
}
