#include <bits/stdc++.h>
using namespace std;
int n, m, a[200010], b[200010];
int main() {
  cin >> n >> m;
  memset(a, 0, sizeof(a));
  for (int i = 1; i <= n + 1; i++)
    scanf("%d", &b[i]), a[i] += b[i], a[i + 1] += a[i] / 2, a[i] %= 2;
  int w = 0;
  for (int i = 1; i <= n + 2; i++)
    if (a[i]) {
      w = i;
      break;
    }
  w = min(n + 1, w);
  long long p = 0;
  for (int i = n + 2; i >= w; i--) {
    p = p * 2 + a[i];
    if (abs(p) > 2 * m) {
      cout << 0 << endl;
      return 0;
    }
  }
  int ans;
  if (w == n + 1 && b[w] - p == 0)
    ans = 0;
  else if (abs(b[w] - p) <= m)
    ans = 1;
  else
    ans = 0;
  for (int i = w - 1; i >= 1; i--) {
    p = p * 2;
    if (abs(b[i] - p) <= m) ans++;
    if (abs(p) > 2 * m) break;
  }
  cout << ans << endl;
  return 0;
}
