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 <bits/stdc++.h>
using namespace std;

int solve(int T, int D, int L) {
    vector<int> X(T);
    vector<int> nure(T + D + 10, 0);
    for (int i = 0; i < T; i++) {
        cin >> X[i];
    }

    for (int i = 0; i < T; i++) {
        if (X[i] >= L) {
            nure[i + 2] += 1;
            nure[i + D + 2] += -1;
        }
    }

    for (int i = 1; i < nure.size(); i++) {
        nure[i] += nure[i - 1];
    }
    int ret = 0;
    for (int i = 0; i <= T; i++) {
        if (nure[i] != 0) ret++;
    }
    // for (int test : nure) cout << test << " ";
    return ret;
}

int main(void) {
    int T, D, L;
    vector<int> ans;
    while (1) {
        cin >> T >> D >> L;
        if (!T && !D && !L) break;
        ans.push_back(solve(T, D, L));
    }
    for (int i : ans) cout << i << endl;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main(){

    for(int T, D, L; cin >> T >> D >> L, T;){
        int ans = 0;
        int lst = 0;
        for(int t = 1; t <= T; t++){
            int x;
            cin >> x;
            if(x < L)continue;
            int nxt = min(T, t + D);
            int diff = nxt - max(t, lst);
            ans += diff;
            lst = nxt;
        }
        cout << ans << endl;
    }

    return 0;
}

C++: #include<stdio.h>
int main(){
	long T,D,L,x[100000];
	while(1){
		int count=0;
		scanf("%d %d %d",&T,&D,&L);
		if(T==0&&D==0&&L==0)break;
		for(int i=0;i<T;i++){
			scanf("%d",&x[i]);
		}
		for(int i=0;i<T;i++){
			if(x[i]>=L){
				count++;
				for(int j=1;j<=D;j++){
					if(x[i+j]<L){
						count++;
					    i++;
					}
					else break;
				}
			}
		}
		printf("%d\n",count);
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int A[2<<17];
int T,D,L;
main()
{
	while(cin>>T>>D>>L,T)
	{
		for(int i=0;i<2<<17;i++)A[i]=0;
		for(int i=0;i<T;i++)
		{
			int x;cin>>x;
			if(x>=L)
			{
				A[i]++;
				A[i+D]--;
			}
		}
		int ans=0;
		for(int i=1;i<1<<17;i++)A[i]+=A[i-1];
		for(int i=0;i<T-1;i++)ans+=A[i]>0;
		cout<<ans<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int T,D,L;
  while(cin>>T>>D>>L,T||D||L){
    Int x[T];
    for(Int i=0;i<T;i++) cin>>x[i];
    Int ans=0,cnt=0;
    for(Int i=0;i<T-1;i++){
      if(cnt) cnt--;
      if(L<=x[i]) cnt=D;
      if(cnt) ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main(){
	int t, d, l;
	while (cin >> t >>d >> l, t) {
		int out = 0; int rest = 0;
		rep(i, t) {
			int x; cin >> x;
			if (x >= l)rest = d;
			if (rest > 0&&i<t-1) {
				out++; rest--;
			}
		}
		cout << out << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int T, D, L;

int main(void)
{
	while(1){
		cin >> T >> D >> L;
		if(T == 0 && D == 0 && L == 0) break;
		
		int rem = 0, h, ans = 0;
		for(int i = 1; i <= T; i++){
			cin >> h;
			if(i == T) continue;
			if(h >= L) rem = D;
			if(rem > 0) ans++;
			rem--;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define ll long long
main() {
    while(1) {
        int t, d, l;
        cin >> t >> d >> l;
        if(!t) return 0;
        int pre = 0;
        int ans = 0;
        for(int i = 0; i < t; ++i) {
            int x;
            cin >> x;
            if(x >= l) {
                int nxt = i + d;
                if(pre < i)
                    ans += d;
                else
                    ans += nxt - pre;
                pre = nxt;
            }
        }
        t--;
        if(pre > t) ans -= pre - t;
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int t, d, l;
void solve() {
	int x, ans = 0, res = 1;
	for (int i = 1; i <= t; i++) {
		cin >> x;
		if (res < i)res = i;
		if (x >= l) {
			ans += min(t, i + d) - res;
			res = min(t, i + d);
		}
	}
	cout << ans << endl;
}
signed main() {
	while (cin >> t >> d >> l && t > 0)solve();
}

C++: #include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  while (true) {
    int t, d, l;
    cin >> t >> d >> l;
    if (t + d + l == 0) return 0;
    
    vector<int> x(t);
    for (int i = 0; i < t; i++) cin >> x.at(i);
    
    vector<int> imos(210000);
    for (int i = 0; i < t; i++) {
      if (x[i] >= l) {
        imos[i + 1]++;
        imos[i + 1 + d]--;
      }
    }
    
    for (int i = 1; i < 209999; i++) imos[i] += imos[i - 1];
    
    int ans = 0;
    for (int i = 1; i <= t - 1; i++) {
      if (imos[i] > 0) ans++;
    }
    
    cout << ans << '\n';
  }
}