#include <bits/stdc++.h>
using namespace std;
int const N = 100;
int x[N];
int main() {
  int n, v;
  scanf("%d%d", &n, &v);
  for (int i = 0; i < (int)(n); ++i) scanf("%d", x + i);
  sort(x, x + n);
  int an = 0, i = 0;
  while (i < n) {
    if (x[i] > v) break;
    v -= x[i];
    ++an;
    ++i;
  }
  if (v) {
    bool ok = false;
    for (int i = an; i < (int)(n); ++i)
      for (int j = 0; j < (int)(an); ++j)
        if (x[j] + v == x[i]) {
          ok = true;
          break;
        }
    if (!ok) --an;
  }
  printf("%d\n", max(0, an));
}
