#include <bits/stdc++.h>
using namespace std;
int T, t, n, m;
long long num[210000], s[210000], K, ans, ret, ret2, temp;
int main() {
  int i, j, k, pos;
  scanf("%d%I64d", &n, &K);
  for (i = 0; i <= n; i++) scanf("%I64d", &num[i]);
  for (i = 0; i <= n + 40; i++) {
    s[i] += num[i];
    s[i + 1] += s[i] / 2;
    s[i] = s[i] % 2;
  }
  for (i = 0; i <= n + 40; i++)
    if (s[i] != 0) break;
  pos = min(n, i);
  ret = 0;
  j = n;
  for (i = n + 40; i > pos; i--) {
    ret = ret * 2 + s[i];
    if (ret > K * 3 || ret < -K * 3) {
      printf("0\n");
      return 0;
    }
  }
  for (i = pos; i >= 0; i--) {
    ret = ret * 2 + s[i];
    if (ret > K * 3 || ret < -K * 3) break;
    ret2 = num[i] - ret;
    if (-K <= ret2 && ret2 <= K && !(i == n && ret2 == 0)) ans++;
  }
  printf("%I64d\n", ans);
}
