#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 100;
const long long inf = 1e10;
long long a[N], b[N], n, k, v, res, cur;
void solve() {
  for (int i = 0; i <= n + v; ++i) {
    b[i] += a[i], b[i + 1] += b[i] / 2;
    if (!(b[i] & 1))
      b[i] = 0;
    else {
      if (b[i] < 0)
        b[i] = -1;
      else if (b[i] > 0)
        b[i] = 1;
    }
  }
  bool check = 0;
  for (int i = n + v; i >= 0; --i)
    if (b[i] == -1) {
      check = 1;
      break;
    } else if (b[i] == 1)
      break;
  if (check)
    for (int i = 0; i <= n + v; ++i) b[i] = -b[i], a[i] = -a[i];
  for (int i = 0; i <= n + v; ++i)
    if (b[i] < 0) b[i] = b[i] / 2 + 1, b[i + 1]--;
  int start = -1;
  for (int i = 0; i <= n + v; ++i) {
    if (!b[i]) continue;
    if (start == -1) {
      start = i, cur = 1;
      continue;
    }
    if (i - start >= 32) return;
    cur += (1LL << (i - start));
  }
  for (int i = start; i >= 0; --i) {
    if (cur > inf) return;
    if (i == n && a[i] == cur) {
      cur <<= 1;
      continue;
    }
    if (fabs(a[i] - cur) <= k && i <= n) res++;
    cur <<= 1;
  }
}
void print() {
  for (int i = 0; i <= n + v; ++i) cout << b[i] << ' ';
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  v = log2(k) + 1;
  for (int i = 0; i <= n; ++i) cin >> a[i];
  solve();
  cout << res;
}
