#include <bits/stdc++.h>
using namespace std;
int children_num(unsigned long long u, unsigned long long l) {
  int sum = 0;
  unsigned long long c;
  for (c = l; c; c >>= 1) {
    if (c & 1) sum++;
  }
  for (c = u; c; c >>= 1) {
    if (c & 1) sum++;
  }
  return sum;
}
int candy_num(int *a, unsigned long long u, unsigned long long l) {
  int i, sum = 0;
  unsigned long long c;
  for (i = 0, c = l; c && i < 64; i++, c >>= 1) {
    if (c & 1) {
      sum += a[i];
    }
  }
  for (i = 0, c = u; c && i < 36; i++, c >>= 1) {
    if (c & 1) sum += a[i + 64];
  }
  return sum;
}
int main() {
  int N, x, a[100] = {}, i, ans = 0, cnum;
  unsigned long long u, l;
  unsigned long long ut, lt;
  cin >> N >> x;
  for (i = 0; i < N; i++) {
    cin >> a[i];
  }
  if (N < 64) {
    lt = 1 << N;
    ut = 0;
  } else {
    lt = 0;
    ut = 1 << (N - 64);
  }
  for (u = l = 0; u != ut || l != lt;) {
    cnum = candy_num(a, u, l);
    if (cnum < x) {
      ans = max(ans, children_num(u, l) - 1);
    } else if (cnum == x) {
      ans = max(ans, children_num(u, l));
    }
    l++;
    if (!l) u++;
  }
  cout << ans << endl;
}
