#include <bits/stdc++.h>
using namespace std;
long long mymod2(long long x) { return llabs(x) % 2; }
int main() {
  int n;
  long long k;
  scanf("%d%I64d", &n, &k);
  vector<long long> a(n + 1);
  vector<long long> aa(n + 1);
  for (int i = 0; i <= n; ++i) {
    scanf("%I64d", &a[i]);
    aa[i] = a[i];
  }
  for (int i = 0; i < n; ++i) {
    if (a[i] > 1 || a[i] < 0) {
      long long newai = mymod2(a[i]);
      long long diff = newai - a[i];
      assert(diff % 2 == 0);
      a[i + 1] -= diff / 2;
      a[i] = newai;
    }
  }
  int maxans = 0;
  while (a[maxans] == 0) {
    ++maxans;
  }
  assert(maxans <= n);
  long long val = 0;
  for (int i = n; i >= maxans; --i) {
    val = val * 2 + a[i];
    if (val > k * 2 || val < k * -2) {
      break;
    }
  }
  int ans = 0;
  for (int i = maxans; i >= 0; --i) {
    if (val > k * 2 || val < k * -2) {
      break;
    }
    long long newval = aa[i] - val;
    if (newval <= k && newval >= -k) {
      if (i == n && newval == 0) {
      } else {
        ++ans;
      }
    }
    val *= 2;
  }
  printf("%d\n", ans);
  return 0;
}
