T = int(input())
for t in range(T):
    n, k = map(int, input().split())
    s = 0
    cnt = 0
    a = list(map(int, input().split()))
    for i in a:
        if i >= k:
            s = s + i
        if i == 0 and s >= 1:
            s = s - 1
            cnt = cnt + 1
    print(cnt)