Go: package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	for {
		t, d, l := io.NextInt(), io.NextInt(), io.NextInt()
		if t == 0 {
			break
		}
		cnt := 0
		elapsed := math.MaxInt32
		for i := 0; i < t-1; i++ {
			x := io.NextInt()
			if x >= l {
				cnt++
				elapsed = 1
			} else if elapsed < d {
				cnt++
				elapsed++
			}
		}
		_ = io.NextInt()
		io.Println(cnt)
	}
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}

C++: #include<iostream>
#include<vector>
using namespace std;

int main()
{
    int t, d, l, a;

    while( cin >> t >> d >> l )
    {
        if( t + d + l == 0 )
            break;

        vector<int> v;
        for( int i = 0; i < t; i++ )
        {
            cin >> a;
            if( v.empty() && a >= l )
            {
                v.push_back( i + 1 );
                v.push_back( i + 1 + d );                
            }
            else if( a >= l && v[v.size()-1] < i + 1 )
            {
                v.push_back( i + 1 );
                v.push_back( i  + 1 + d );
            }
            else if( a >= l )
            {
                v.pop_back();
                v.push_back( i + 1 + d );
            }
        }

        if( !v.empty() )
        {
            if( v[v.size()-1] > t )
                v[v.size()-1] = t;

            if( v[v.size()-2] == t )
            {
                v.pop_back();
                v.pop_back();
            }
        }

        int sum = 0;
        for( int i = 0; i < v.size(); i += 2 )
            sum += v[i+1] - v[i];

        cout << sum << endl;

        v.clear();
    }

    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int t, d, l;
    while (cin >> t && t) {
        cin >> d >> l;
        int sum = 0;
        int wet = 1;
        rep(i, t) {
            int x; cin >> x;
            if (x < l || i == t - 1) continue;
            chmax(wet, i + 1);
            sum += max(0, min(t, d + (i + 1)) - wet);
            wet = d + (i + 1);
            //out(sum << " " << wet);
        }
        out(sum);
    }
}

C++: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

namespace FastFourierTransform
{
	using C = complex< double >;

	void DiscreteFourierTransform(vector< C > &F, bool rev)
	{
		const int N = (int)F.size();
		const double PI = (rev ? -1 : 1) * acos(-1);
		for (int i = 0, j = 1; j + 1 < N; j++) {
			int k=N>>1;
			for (; k > (i ^= k); k >>= 1);
			if (i > j) {
				swap(F[i], F[j]);
			}
		}
		C w, s, t;
		for (int i = 1; i < N; i <<= 1) {
			for (int k = 0; k < i; k++) {
				w = polar(1.0, PI / i * k);
				for (int j = 0; j < N; j += i * 2) {
					s = F[j + k];
					t = C(F[j + k + i].real() * w.real() - F[j + k + i].imag() * w.imag(),
						F[j + k + i].real() * w.imag() + F[j + k + i].imag() * w.real());
					F[j + k] = s + t, F[j + k + i] = s - t;
				}
			}
		}
		if (rev) for (int i = 0; i < N; i++) F[i] /= N;
	}

	vector< long long > Multiply(const vector<long long int > &A, const vector<long long int > &B)
	{
		int sz = 1;
		while (sz <= A.size() + B.size()) sz <<= 1;
		vector< C > F(sz), G(sz);
		for (int i = 0; i < A.size(); i++) F[i] = A[i];
		for (int i = 0; i < B.size(); i++) G[i] = B[i];
		DiscreteFourierTransform(F, false);
		DiscreteFourierTransform(G, false);
		for (int i = 0; i < sz; i++) F[i] *= G[i];
		DiscreteFourierTransform(F, true);
		vector< long long > X(A.size() + B.size() - 1);
		for (int i = 0; i < A.size() + B.size() - 1; i++) X[i] = F[i].real() + 0.5;
		return (X);
	}
};

long long int comb(long long int a, long long int k) {
	if(k==0)return 1;
	if(k==a)return 1;
	return comb(a-1,k-1)+comb(a-1,k);
}

long long int solve(int k,const vector<int>&v,vector< int>nums, const int now) {
	if (now == 10) {
		long long int ans=1;
		int sum=accumulate(nums.begin(),nums.end(),0);
		int rest=sum;
		for (int i = 0; i < 10; ++i) {
			if (nums[i]) {
				ans*=comb(rest,nums[i]);
				rest-=nums[i];
			}
		}
		if (nums[0]) {
			long long int nans=1;
			int rest=sum-1;
			for (int i = 0; i < 10; ++i) {
				if (nums[i]) {
					if(i==0)nans*=comb(rest,nums[i]-1);
					else nans*=comb(rest,nums[i]);

					if(i==0)rest-=nums[i]-1;
					else rest-=nums[i];
				}
			}
			ans-=nans;
		}
		return ans;
	}
	else {
		if (v[now]) {
			long long int ans=0;

			for (int x = 1; x <= v[now];++x) {
				nums[now]=x;
				ans += solve(k, v, nums, now + 1);
			}
			return ans;
		}
		else {
			nums[now]=0;
			return solve(k,v,nums,now+1);
		}
	}
}

int main()
{
	while (true) {
		int T,D,L;cin>>T>>D>>L;
		if(!T)break;
		int ans=0;
		int k=0;
		for (int i = 0; i < T; ++i) {
			int a;cin>>a;
			if(i==T-1)break;
			if (a >= L) {
				k=D;
			}
			if (k > 0) {
				ans++;
				k--;
			}

		}
		cout<<ans<<endl;
	}
	return 0;
}