#include <bits/stdc++.h>
using namespace std;
const int N = 500000;
const int K = 60;
int n, k;
long long a[N + 110], b[N + 110];
long long Abs(long long x) { return (x < 0) ? (-x) : x; }
void Update() {
  for (int i = 1; i <= n + K; i++) {
    if (a[i] >= 0) {
      a[i + 1] += a[i] / 2;
      a[i] %= 2;
      continue;
    }
    a[i + 1] -= (-a[i] + 1) / 2;
    a[i] = (a[i] % 2 + 2) % 2;
  }
}
void work1() {
  int kx = n + K + 1;
  while (kx > 1 && a[kx] == 0) kx--;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (kx <= i + K) {
      long long now = 0;
      for (int j = i; j <= i + K; j++)
        if (a[j]) now += (1ll << (j - i));
      if (Abs(b[i] - now) <= k) {
        ans++;
        if (i == n && b[i] == now) ans--;
      }
    }
    if (a[i] != 0) break;
  }
  printf("%d\n", ans);
}
void work2() {
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n; i++) a[i] = -b[i];
  Update();
  int kx = n + K + 1;
  while (kx > 1 && a[kx] == 0) kx--;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (kx <= i + K) {
      long long now = 0;
      for (int j = i; j <= i + K; j++)
        if (a[j]) now += (1ll << (j - i));
      if (Abs(b[i] + now) <= k) {
        ans++;
        if (i == n && b[i] + now == 0) ans--;
      }
    }
    if (a[i] != 0) break;
  }
  printf("%d\n", ans);
}
int main() {
  scanf("%d%d", &n, &k);
  n++;
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    b[i] = a[i];
  }
  Update();
  if (a[n + K + 1] >= 0)
    work1();
  else
    work2();
  return 0;
}
