#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<pii>;
using ll = long long;
using ld = long double;
const int maxn = 4e5;
const int lo = 40;
int a[maxn];
int b[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  ll k;
  cin >> n >> k;
  ++n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll c = 0;
  int p;
  for (p = 0; p < n; ++p) {
    c += a[p];
    if (c % 2 != 0) {
      b[p] = 1;
      --c;
    }
    c /= 2;
  }
  if (c < 0) {
    for (int i = 0; i < n; ++i) {
      a[i] = -a[i];
    }
    c = 0;
    for (p = 0; p < n; ++p) {
      c += a[p];
      if (c % 2 != 0) {
        b[p] = 1;
        --c;
      } else {
        b[p] = 0;
      }
      c /= 2;
    }
  }
  while (c > 0) {
    if (c % 2 != 0) {
      b[p] = 1;
      --c;
    }
    c /= 2;
    ++p;
  }
  int p1 = -1, p2 = -1;
  for (int i = 0; i < p; ++i) {
    if (b[i] == 1) {
      if (p1 == -1) {
        p1 = i;
      }
      p2 = i;
    }
  }
  if (p2 - p1 > lo) {
    cout << "0\n";
    return 0;
  }
  int res = 0;
  for (int i = max(p2 - lo, 0); i <= min(p1, n - 1); ++i) {
    ll t = 0, pc = 1;
    for (int j = i; j <= p2; ++j) {
      if (b[j] == 1) {
        t += pc;
      }
      pc *= 2;
    }
    if (abs(ll(a[i]) - t) <= k && (i != n - 1 || ll(a[i]) - t != 0)) {
      ++res;
    }
  }
  cout << res << '\n';
  return 0;
}
