#include <bits/stdc++.h>
using namespace std;
long long arr[200005];
long long vis[200005];
int n, k;
long long LL = 2000000000;
long long ab(long long b) {
  if (b >= 0)
    return b;
  else
    return -b;
}
void init() {
  long long ad = 0;
  for (int i = 0; i <= n; i++) {
    vis[i] = arr[i];
  }
  for (int i = 0; i <= n - 1; i++) {
    ad = arr[i] / 2;
    arr[i + 1] += ad;
    arr[i] = arr[i] % 2;
  }
  int cnt = 0;
  for (int i = 0; i <= n; i++) {
    cnt = i;
    if (arr[i] != 0) {
      break;
    }
  }
  long long sum = 0;
  for (int i = n; i >= cnt; i--) {
    sum = sum * 2 + arr[i];
    if (ab(sum) > LL) {
      cout << "0";
      return;
    }
  }
  int ans = 1;
  if ((cnt == n && sum - vis[cnt] == 0) || ab(vis[cnt] - sum) > k) ans = 0;
  for (int i = cnt - 1; i >= 0; i--) {
    sum = sum * 2;
    if (ab(sum) > LL) break;
    if (ab(vis[i] - sum) > k) {
      continue;
    }
    ans++;
  }
  cout << ans << endl;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i <= n; i++) {
    scanf("%I64d", &arr[i]);
  }
  init();
  return 0;
}
