fun main(args:Array<String>):Unit{
    val (t,d,l) = readLine()!!.split(' ').map(String::toInt)
    f(t, d, l)
}
tailrec fun f(t:Int, d:Int, l:Int):Unit{
    if (t != 0 && d != 0 && l != 0){
        var prev = 1 - d
        var timeSum = - d
        for (time in 1 .. t){
            val x = readLine()!!.toInt()
            if (x >= l){
                if (time - prev > d){
                    timeSum += d
                    prev = time
                }else{
                    timeSum += time - prev
                    prev = time
                }
            }
        }
        if (t - prev > d){
            timeSum += d
        }else{
            timeSum += t - prev
        }
        println(timeSum)
        val (tt, dd, ll) = readLine()!!.split(' ').map(String::toInt)
        f(tt, dd, ll)
    }
}
