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++: #define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int t, d, l;
		cin >> t >> d >> l;
		if (t == 0) return;
		int now = 0;
		int ans = 0;
		REP(i, t) {
			int geko;
			cin >> geko;
			now--;
			if (now > 0) {
				ans++;
			}
			if (geko >= l) {
				now = d+1;
			}
		}
		cout << ans << endl;
	}
}
#undef int
int main() {
	init();
	solve();
}

C++: #include <stdio.h>

int main(){
	int T,D,L;
	for(;~scanf("%d%d%d",&T,&D,&L)&&T&&D&&L;){
		int r=0;
		for(int i=0,x,y=0;i<T;i++){
			if(--y>=0)r++;
			scanf("%d",&x);
			if(x>=L)y=D;
		}
		printf("%d\n",r);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int t,d,l;
int x[100100];
int wave[100100];

int main(){
	while(1){
		cin>>t>>d>>l;
		if(t==0&&d==0&&l==0)break;
		REP(i,100100)wave[i]=0;
		for(int i=1;i<=t;i++){
			int ll;
			cin>>ll;
			if(ll>=l){
				for(int j=0;j<d&&i+j<t;j++){
					wave[i+j]=1;
				}
			}
		}
		int ans=0;
		for(int i=1;i<t;i++){
			if(wave[i]==1)ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

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

using namespace std;

int main()
{
  while(1){
    int T,D,L;
    cin>>T;
    cin>>D;
    cin>>L;

    if(T == 0 && D == 0 && L == 0){
      break;
    }

    int lt = 0;
    int temp = 0;
    int times = 0;
    int check = 0;

    for(int i = 0;i < T;++i){
      cin>>temp;

      if(check == 0){
        if(temp >= L){
          lt = i;
          check = 1;
        }
      }
      else{
        if(temp >= L){
          times += i - lt;
          lt = i;
        }
        else{
          if(i - lt == D){
            times += D;
            check = 0;
          } 
          else if(i - lt < D && i == T - 1){
            times += i - lt;
          }
        }
      }
    }
    cout<<times<<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){
				for(int j=1;j<=D;j++){
					if((i+j)==T)goto end;
					if(x[i+j]<L){
						count++;
					}
					else{
						count++;
						break;
					}
				}
			}
		}
end:		
		printf("%d\n",count);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define range(i,a,b) for(long long i = (a); i < (b); i++)
#define rep(i,b) for(long long i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
 
template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}
template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	int t, d, l;
	while(cin >> t >> d >> l, t){
		int ans = 0;
		int sum = 0, cur = 0;
		rep(i,t){
			int x;
			cin >> x;

			if(cur <= 0){
				ans += sum;
				sum = 0;
			}else{
				sum++;
			}

			if(l <= x){
				cur = d;
			}else{
				cur--;
			}

		}
		ans = max(ans, sum);
		cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  while (true) {
    ll t, d, l;
    cin >> t >> d >> l;
    if (t == 0)
      break;
    vector<ll> x(t);
    for (int i = 0; i < t; i++)
      cin >> x[i];
    ll ans = 0;
    ll turn = 0;
    for (int i = 0; i < t; i++) {
      if (turn > 0) {
        turn--;
        ans++;
      }
      if (l <= x[i]) {
        turn = d;
      }
    }
    cout << ans << endl;
  }
  return 0;
}