#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 32;
int n, m, num[MAX], mult = 1;
long long arr[MAX];
int solve() {
  int ret = 0;
  for (int i = 0; i < MAX - 2; ++i) {
    while (num[i] < 0) num[i] += 2, num[i + 1] -= 1;
    while (num[i] > 1) num[i] -= 2, num[i + 1] += 1;
  }
  if (num[MAX - 1] < 0) return ret;
  int l = -1, r;
  for (int i = 0; i < MAX - 1; ++i)
    if (num[i]) {
      r = i;
      if (l == -1) l = i;
    }
  if (r - l + 1 > 30) return ret;
  long long now = 0;
  for (int i = l; i <= r; ++i)
    if (num[i]) now += (1 << (i - l));
  if (l > n) now = now << (l - n);
  for (int i = min(n, l); i >= 0 && (now <= (m << 1)); --i) {
    if (abs(arr[i] - (now * mult)) <= m &&
        !(i == n && abs(arr[i] - (now * mult)) == 0))
      ++ret;
    now <<= 1;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n + 1; ++i) {
    int mult = 1, in;
    cin >> in;
    arr[i] = in;
    if (in < 0) mult = -1, in = -in;
    for (int j = 0; in; ++j) {
      num[i + j] += (in & 1) * mult;
      in >>= 1;
    }
  }
  int tmp = solve();
  mult = -1;
  for (int i = 0; i < MAX - 1; ++i) num[i] = -num[i];
  cout << tmp + solve();
  return 0;
}
