#include <bits/stdc++.h>
using namespace std;
long long inf = (long long)(1e15);
int a[300010], b[300010];
int main() {
  int n, m, i, p, ans = 0, flag = 0, k, j;
  long long now = 0;
  scanf("%d %d", &n, &m);
  for (i = 0; i <= n; i++) scanf("%d", &a[i]), b[i] = a[i];
  for (i = n; i >= 0; i--) {
    now = now * 2 + a[i];
    if (abs(now) > inf) break;
  }
  if (now < 0)
    for (i = 0; i <= n; i++) a[i] = -a[i], b[i] = a[i];
  for (i = 0; i <= n || a[i]; i++) {
    if (a[i] < 0)
      a[i + 1] += (a[i] - 1) / 2, a[i] = -a[i] % 2;
    else
      a[i + 1] += a[i] / 2, a[i] %= 2;
    if (a[i] != 0 && !flag) flag = 1, k = i;
  }
  k = min(k, n);
  now = 0;
  for (p = i - 1; p >= 0; p--) {
    now = now * 2 + a[p];
    if (abs(now) > inf) break;
    if (p <= k && abs(b[p] - now) <= m && (p != n || b[p] != now)) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
