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 <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int T, D, L;
int cnt;
int x;
int ans;
bool debug = true;

int main() {
	
	while( cin>>T>>D>>L, (T||D||L) ){
		cnt = 112345;
		ans = 0;
		REP( i, T ){
			cin>>x;
			if( x >= L ) cnt = 0;
			cnt++;
			if( cnt <= D && ( i != (T-1) ) ) ans++;
		}
		//if( debug ) cout<<"@ "; 
		cout<<ans<<endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int a[1<<17],t,d,l;
main()
{
	while(cin>>t>>d>>l,t)
	{
		for(int i=0;i<t;i++)
		{
			int x;cin>>x;
			a[i]=x<l?0:d;
		}
		int ans=0;
		for(int i=0;i<t-1;i++)
		{
			ans+=!!a[i];
			a[i+1]=max(a[i+1],a[i]-1);
		}
		cout<<ans<<endl;
	}
}

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

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

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

C++: #include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;

int main() {
	vector<int> anss;
	while (true) {
		int t, d, l;
		cin >> t >> d >> l;
		if (t == 0 && d == 0 && l == 0)break;
		int a;
		int tmp = 0;
		int ans = 0;
		for (int i = 0; i < t;i++) {
			cin >> a;
			if (a >= l) {
				tmp = i + d;
			}
			if (tmp <= i) {
				ans++;
			}
		}
		anss.push_back(t - 1 - ans);
	}
	for (int i = 0; i < anss.size(); i++) {
		if (anss[i] < 0) {
			cout << 0 << endl;
		}
		else {
			cout << anss[i] << endl;
		}
	}
	return 0;
}

C++: #include <cstdio>

int main(){
	int T,D,L,x;	
	while(scanf("%d%d%d",&T,&D,&L), T != 0){
		int ans = 0, cont = -1;
		for(int i = 0; i < T; i++){
			scanf("%d",&x);
			if(cont >= i){
				ans++;
			}
			if(x >= L){
				cont = i + D;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int t,d,l,x;
    while(cin>>t>>d>>l,t|d|l){
        int cur=0,cnt=0;
        rep(i,t){
            cin>>x;
            if(x>=l) cur=d;
            if(cur>0&&i<t-1) ++cnt;
            if(cur>0)--cur;
        }
        cout<<cnt<<endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T,D,L;
    cin >> T >> D >> L;
    while(T != 0){
        vector<int> X(T);
        for(int i=0; i<T; i++){
            cin >> X[i];
        }
        int ok = 0;
        int ans = 0;
        for(int i=0; i<T; i++){
            if(ok) ans++;
            if(X[i] >= L) ok = D+1;
            if(ok) ok--;
        }
        cout << ans << enld;
        cin >> T >> D >> L;
    }


    return 0;
}

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

int main()
{
	int T, D, L;
	while (cin >> T >> D >> L, T | D | L) {
		int last = -D, res = 0;
		for (int i = 0; i < T; i++) {
			int w;
			cin >> w;
			if (w >= L) last = i;
			if (i + 1 < T) res += i < last + D;
		}
		cout << res << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main () {

  int n, d, l, wave;
  
  while (1) {

    cin >> n >> d >> l;
    if (n + d + l == 0)
      break;

    else {

      int ans = 0;
      int wet = 0;

      for (int i = 0; i < n; i++) {

        cin >> wave;

        if (wet > 0) {
          ans++;
          wet--;
        }

        if (wave >= l)
          wet = d;
      }

      cout << ans << endl;
    }
  }
}