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 main() {
	while(1) {
		int t, d, l;
		cin >> t >> d >> l;
		if((t == 0)&&(d == 0)&&(l == 0)) {
			break;
		} else {
			int ans = 0, head = 0, tail = 0;
			for(int i = 1; i <= t; i++) {
				int x;
				cin >> x;

				if(l <= x) {
					if(head == 0) head = i;
					tail = i + d;
				}
				if(tail == i) {
					ans += tail - head;
					head = 0;
					tail = 0;
				}
			}
			if(head != 0) ans += t - head;

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

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;

#define abs(a) ((a) < (0)? -(a):(a))
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)
#define pb push_back

int T, D, L;

int main() {
    while(cin>>T>>D>>L, T+D+L) {
        int ans = 0, d = 0;
        rep(i, T) {
            int x; cin >> x;
            if(x >= L) d = D;
            else d = max(d-1, 0);
            if(d > 0) ans++;
        }
        cout << max(ans-1, 0) << endl;
    }
}

C++: #include "iostream"
#include "random"
#include "string"
#include "bitset"
#include "algorithm"
#include "map"
#include "queue"
#include "list"
#include "set"
#include "climits"
#include "iomanip"
#include "stack"
#include "functional"

using namespace std;

int N, M, K, L, R, H, W;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> M >> K;
	while (N) {
		vector<int>v(200001);
		for (int i = 1; i <= N; i++) {
			cin >> L;
			if (L >= K) {
				v[i]++;
				v[i + M]--;
			}
		}
		int ans = 0;
		for (int i = 1; i < N; i++) {
			v[i] += v[i - 1];
			if (v[i])ans++;
		}
		cout << ans << endl;
		cin >> N >> M >> K;
	}
}

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

typedef long long ll;

ll t,d,l;
ll x[100005];
ll i;
ll ans;

bool solve(){
	cin >> t >> d >> l;
	if(t == 0){
		return false;
	}
	for(i=0;i<t;i++){
		cin >> x[i];
	}
	ll value = 0;
	ans = 0;
	for(i=0;i<t-1;i++){
		if(x[i] >= l)value = d;
		if(value >= 1){
			ans++;
			value--;
		}
	}
	cout << ans << endl;
	return true;
}

int main(){
	while(solve()){}
	return 0;
}

C++: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1LL<<59)


signed main(){
    int t,d,l;
    while(cin>>t>>d>>l&&(t||d||l)){
        vector<int> x(t);
        rep(i,t)cin>>x[i];

        vector<int> imos(1000000,0);
        rep(i,t){
            if(x[i]>=l){
                imos[i]++;
                imos[i+d]--;
            }
        }

        rep(i,imos.size()-1)imos[i+1]+=imos[i];

        int ans = 0;
        for(int i=0;i<t-1;i++)if(imos[i]!=0)ans++;
        cout<<ans<<endl;
    }
}

C++: #include <iostream>
using namespace std;
int main(){
    while(1){
        int T,D,L;
        cin >> T >> D >> L;
        if(T==0 && D==0 && L==0){
            break;
        }

        int last=-D;
        int ans=0;
        for(int t=1; t<=T; t++){
            int x;
            cin >> x;

            if(t<=last+D){
                ans++;
            }

            if(x>=L){
                last=t;
            }
        }

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t, d, l;
    while (cin >> t >> d >> l) {
        if (t == 0) break;
        int last = -1e9;
        int cnt = 0;
        for (int i = 0; i < t; i++) {
            int a;
            cin >> a;
            if (i == t - 1) continue;
            if (a >= l) {
                last = i;
                cnt++;
            } else if (i - last < d) cnt++;
        }
        cout << cnt << '\n';
    }
}

C++: /////16:35~
/////B:

#include<iostream>

using namespace std;
int main(){
    while(true){
        int T,D,L;
        cin>>T>>D>>L;
        if(T==0)return 0;
        int count = 0;
        int ans = 0;
        for(int i = 0;i<T;i++){
            int x;
            cin>>x;
            if(i==T-1)break;
            if(x>=L)count = D;
            if(count>0)ans++;
            count--;
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(void){
	int n,m,l;
	int x;
	while(scanf("%d %d %d",&n,&m,&l),n||m||l){
		int z=0;
		int ans=0;
		for(int i=0;i<n;i++){
			scanf("%d",&x);
			if(x>=l)z=m;
			if(z>0)ans++;
			z--;
		}
		cout<<(ans>0?ans-1:ans)<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

bool solve(){
  int t,d,l;
  
  scanf("%d%d%d",&t,&d,&l);

  if(t == 0) return false;

  int ans = 0;
  int sec = 0;
  
  for(int i=0;i<t;i++){
    int x;

    scanf("%d",&x);

    if(t-1 == i) continue;
    
    sec--;
    if(x >= l){
      sec = d;
    }

    if(sec > 0) ans++;
  }

  
  printf("%d\n",ans);

  return true;
}

int main(){
  while(solve());
  
  return 0;
}