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>
#include <algorithm>

using namespace std;


int main(void) {
	int x,res,rest,T,D,L;
	while (cin >> T >> D >> L,T,D,L) {
		res = rest = 0;
		for (int i = 0; i < T; ++i) {
			cin >> x;
			if (i < T-1) {
				if (x >= L) {
					rest = D;
				}
				else {
					--rest;
				}
				if (rest > 0) {
					++res;
				}
			}
		}
		cout << res << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	while(1){
		long long int T,D,L,i[1000]={0},wet[1000]={0},num=0;
		cin>>T>>D>>L;
		if(T==0&&D==0&&L==0)	break;
		for(int y=0;y<T;y++){
			cin >> i[y];
			if(i[y]>=L){
				for(int x=y;x<D+y;x++){
					wet[x] = 1;
				}
			}
		}
		for(int y=0;y<T-1;y++){
			num = num+wet[y];
		}
		cout  << num <<"\n";
}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
#define MAX_N 10000000
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t, d, l;
	while(cin >> t >> d >> l, t | d | l)
	{
		int cnt = 0;
		int b = -MAX_N;
		for(int i = 0; i < t; i++)
		{
			int x;
			cin >> x;
			if(i + 1 == t)
				continue;
			if(x >= l){
				b = i;
			}
			cnt += i - b<d;
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define sq(x) ((x)*(x))
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int solve(){
	int T,D,L;
	cin >> T >> D >> L;
	if(T+D+L==0)return 1;
	vector<int> x(T);
	vector<int> rui(200100);
	for(int i=0;i<T;i++){
		cin >> x[i];
		if(x[i]>=L){
			rui[i]++;
			rui[i+D]--;
		}
	}
	for(int i=1;i<200100;i++)rui[i]+=rui[i-1];
	//for(int i=0;i<=T;i++)cout << i << ':' << rui[i] << endl;
	int ans = 0;
	for(int i=0;i<T-1;i++)if(rui[i])ans++;
	cout << ans << endl;
	return 0;
}
int main(){
	while(!solve()){}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int T, D, L;
    cin >> T >> D >> L;
    if (T == 0 && D == 0 && L == 0){
      break;
    }
    vector<int> x(T);
    for (int i = 0; i < T; i++){
      cin >> x[i];
    }
    vector<int> d(T + 1, 0);
    for (int i = 0; i < T; i++){
      if (x[i] >= L){
        d[i]++;
        d[min(i + D, T)]--;
      }
    }
    for (int i = 0; i < T; i++){
      d[i + 1] += d[i];
    }
    int ans = 0;
    for (int i = 0; i < T - 1; i++){
      if (d[i] > 0){
        ans++;
      }
    }
    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

void solve(int T, int D, int L){
  int x;
  map<double, int> time;
  for(int i = 1; i <= T; i++){
    cin >> x;
    if(L <= x) {
      time[i +  0.5]++;
      time[i + D + 0.5]--;
    }
  }
  for(int i = 1; i < T + D + 10; i++) time[i + 0.5] += time[i - 0.5];
  // for(int i = 0; i < T; i++) //cerr << i + 0.5 << " " << time[i + 0.5] << endl;
  int ans = 0;
  for(int i = 0; i < T; i++) ans += bool(time[i + 0.5]);
  cout << ans << endl;
}

int main(){
  int T, D, L;
  while(cin >> T >> D >> L) {
    if(T == 0 && D == 0 && L == 0) break;
    solve(T, D, L);
  }
  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>
using namespace std;

int solve_testcase() {
    int T, D, L; cin >> T >> D >> L;
    if(T == 0) return 1;

    const int INF = 1e9;
    int last = -INF, ans = 0;
    for(int i=0; i<T; i++) {
        int x; cin >> x;
        if(last != -INF) ans++;
        if(x >= L) last = i;
        if(i - last == D) last = -INF;
    }

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

int main() {
    while(!solve_testcase());
    return 0;
}