package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())

	for i := 0; i < t; i++ {
		s, cnt := 0, 0
		sc.Scan()
		n, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		for j := 0; j < n; j++ {
			sc.Scan()
			tmp, _ := strconv.Atoi(sc.Text())
			if tmp >= k {
				s = s + tmp
			} else if tmp == 0 && s >= 1 {
				s -= 1
				cnt += 1
			}
		}
		fmt.Println(cnt)
	}
}