#include "biscuits.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define DEBUG 0
long long count_tastiness(long long x, std::vector<long long> a) {
vector<ll> answers = {};
vector<ll> tot = {};
int bi = 0;
while(true){
#if DEBUG
if((x<<bi > 1000)) break;
#else
if((x<<bi) > 1e18) break;
#endif
if(bi == 0) tot.push_back(0);
else tot.push_back(tot.back());
if(bi < a.size()) tot[bi] += a[bi] << bi;
ll needed = 0;
ll curans = 0;
for(int curbit = bi; curbit >= 0; curbit--){
if(tot[curbit] >= needed + (x << curbit)){
needed += (x<<curbit);
if(curbit != 0) curans += answers[curbit-1]+1;
else curans += 1;
}
if(curbit < a.size()) needed = max(0ll, needed-(a[curbit]<<curbit));
}
answers.push_back(curans);
bi++;
}
// for(auto& x : answers){
// cout << x << " ";
// }
// cout << endl;
return answers.back()+1;
}
#if DEBUG
signed main(){
int q;
cin >> q;
for(int i = 0; i< q; i++){
ll n,x;
cin >> n >> x;
vector<ll> a(n);
for(auto& x : a) cin >> x;
int ans = count_tastiness(x,a);
cout << ans << endl;
}
}
#endif