#include <bits/stdc++.h>
using namespace std;
inline void printInt(int a) { printf("%d", a); }
inline void printDbl(double a) { printf("%.10lf", a); }
inline int getInt() {
  int res;
  scanf("%d", &res);
  return res;
}
inline double getDbl() {
  double res;
  scanf("%lf", &res);
  return res;
}
const int maxn = 200100;
long long int a[maxn];
long long int b[maxn];
int n;
int sign(long long int x) { return x < 0 ? -1 : x == 0 ? 0 : 1; }
void copy() {
  for (int i = (0); i < (n); i++) a[i] = b[i];
}
int eval() {
  for (int i = (0); i < (n - 1); i++) {
    long long int v = a[i];
    a[i] = v % 2;
    a[i + 1] += v / 2;
    if (a[i] == -1) {
      a[i] = 1;
      a[i + 1]--;
    }
  }
  for (int i = n - 1; i >= 0; i--)
    if (a[i] != 0) return sign(a[i]);
  return 0;
}
int main() {
  srand(time(0));
  n = getInt() + 1;
  long long int k = getInt();
  for (int i = (0); i < (n); i++) {
    b[i] = getInt();
  }
  copy();
  eval();
  int maxi = -1;
  for (int i = (0); i < (n); i++) {
    if (a[i] != 0) {
      maxi = i;
      break;
    }
  }
  long long int l = -4LL * k - 10, r = 4LL * k + 10;
  copy();
  a[maxi] = l;
  int s1 = eval();
  copy();
  a[maxi] = r;
  int s2 = eval();
  if (s1 == s2 || s1 * s2 == 0) {
    printf("0");
    return 0;
  }
  while (l + 1 < r) {
    long long int m = (l + r) / 2LL;
    copy();
    a[maxi] = m;
    int s = eval();
    if (s == s2) {
      r = m;
    } else {
      l = m;
    }
  }
  long long int dif = l - b[maxi];
  copy();
  a[maxi] = b[maxi] + dif;
  assert(eval() == 0);
  int cnt = 0;
  for (int i = maxi; i >= 0; i--) {
    if (abs(dif) > 2 * k + 10) break;
    long long int v = b[i] + dif;
    if (abs(v) <= k && (i < n - 1 || v != 0)) {
      cnt++;
    }
    dif *= 2;
  }
  cout << cnt;
  return 0;
}
