#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 5;
const int mod = 1000000007;
long long a[N];
long long rep[N];
long long ps[N];
int main() {
  long long n, k;
  scanf("%lld", &n);
  scanf("%lld", &k);
  for (long long i = 0; i <= n; i++) {
    scanf("%lld", &a[i]);
    rep[i] = a[i];
    ps[i] = a[i];
  }
  long long ptr = 0;
  for (long long i = 0; i < n; i++) {
    ps[i + 1] += ps[i] / 2;
    ps[i] %= 2;
  }
  for (long long i = 0; i <= n; i++) {
    if (ps[i]) {
      ptr = i;
      break;
    }
  }
  long long ans = 0;
  long long sum = 0;
  for (long long i = n; i >= 0; i--) {
    sum *= 2;
    sum += ps[i];
    if (sum > (INT_MAX) || sum < ((INT_MIN))) break;
    if (i > ptr) continue;
    if ((sum == rep[i]) && i == n) continue;
    if (abs(sum - rep[i]) <= k) ans++;
  }
  printf("%lld ", ans);
  printf("\n");
  return 0;
}
