#include <bits/stdc++.h>
using namespace std;
const long long maxn = 100000000000000;
long long lower[200010], k;
long long a[200010];
int n;
int solve() {
  int cnt = 0;
  int flag = a[n - 1];
  for (int i = 0; i < n - 1; i++) {
    if (a[i] % 2) {
      a[i + 1] += (a[i] - 1) / 2;
      a[i] = 1;
    } else {
      a[i + 1] += a[i] / 2;
      a[i] = 0;
    }
  }
  long long tot = 0;
  int pos = n - 1;
  flag = a[n - 1] - flag;
  for (int i = 0; i < n; i++) {
    if (i && a[i - 1]) return cnt;
    while (lower[i] <= -tot && -tot <= 2 * k + lower[i] && pos >= i) {
      tot *= 2;
      tot += a[pos--];
    }
    if (pos < i && lower[i] <= -tot && -tot <= 2 * k + lower[i]) {
      if (i == n - 1 && flag == 0) return cnt;
      cnt++;
      tot /= 2;
    } else if (pos < i) {
      tot /= 2;
    }
  }
  return cnt;
}
int main() {
  for (; scanf("%d%I64d", &n, &k) != EOF;) {
    n++;
    fill(lower, lower + n, -k);
    for (int i = 0; i < n; i++) {
      scanf("%I64d", &a[i]);
      lower[i] -= a[i];
    }
    cout << solve() << endl;
  }
}
