import sys

input = sys.stdin.read().split()
ptr = 0
number_group = int(input[ptr])
ptr += 1

for i in range(number_group):
    n = int(input[ptr])
    ptr += 1
    k = int(input[ptr])
    ptr += 1
    a = list(map(int,input[ptr:ptr+n]))
    ptr += n

    S = cnt = 0
    for j in range(n):
        if a[j] >= k:
            S = S +a[j]
        elif a[j] == 0 and S >= 1:
            S -= 1
            cnt +=  1
    print(cnt)