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