#include <bits/stdc++.h>
#define I_can_AK int main
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vst = vector<string>;
const int MAXN = 1e6 + 5;
void Solve(){
int T;
cin >> T;
while(T--){
int n,k;
cin >> n >> k;
vector<int>arr(n);
for(int i = 0; i < n;i++){
cin >> arr[i];
}
int s=0;
int m=0;
for(int i =0;i < n;i++){
if(arr[i]>=k){
s+=arr[i];
}
if(arr[i]==0&&s!=0){
s-=1;
m+=1;
}
}
cout << m << "\n";
}
return ;
}
I_can_AK(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr); std::cout.tie(nullptr);
int _ = 1;
//std::cin >> _;
while(_--) Solve();
return 0;
}