#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200000 + 10;
int N, K, lowbit, ans;
int a[MAXN], bin[MAXN];
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i <= N; ++i) {
    scanf("%d", a + i);
    bin[i] += a[i];
    bin[i + 1] += bin[i] / 2;
    bin[i] %= 2;
  }
  for (lowbit = 0; lowbit <= N and !bin[lowbit]; ++lowbit)
    ;
  long long arg = bin[N + 1];
  long long KK = (long long)K * 2;
  for (int i = N; i >= 0; --i) {
    arg = arg * 2 + bin[i];
    if (abs(arg) > KK) break;
    if (i <= lowbit and abs(arg - a[i]) <= K and (i != N || a[i] != arg)) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}
