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>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int T, D, L;
    while (cin >> T >> D >> L, T) {
        int ans = 0, rem = 0;
        REP (i, T) {
            int x;
            cin >> x;
            if (rem) {
                ans++;
                rem--;
            }
            if (x >= L) rem = D;
        }
        cout << ans << endl;
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int t,d,l;
  int check = 0;
  int num = 0;

  while(cin >> t >> d >> l){
    if(t == 0 && d == 0 && l == 0){ break; }

    for(int i = 0; i< t; i++){
        cin >> x;
        if(i != t-1){
            if(x >= l){ check = d; }
            if(check > 0){
                num++;
                check--;
            }
        }
    }

  }

  cout << num << endl;

  return 0;
}

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

using ll = long long;

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

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

int main(){
  int T,D,L;
  while(cin>>T>>D>>L,T){
    int sum=0;
    int pre=0;
    int wle=0;
    for(int i=0;i<T;i++){
      int a;
      cin>>a;
      //if(wle)sum++;
      if(wle)sum++;
      if( L<=a ){
        pre = i;
        wle=1;
      }
      //if(wle)sum++;
      if(i-pre>=D) wle=0;
    }
    cout<<sum<<endl;
  }
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(){
	while(1){
		long long int T,D,L,i[1000000]={0},wet[1000000]={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 <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int t,d,l;
	while(cin>>t>>d>>l,t){
	    int ans=0,r=0,p;
		rep(i,t){
		    cin>>p;
		    if(p>=l)r=d;
		    if(i+1!=t and r>0){
		        ans++;
		        r--;
		    }
		}
		cout<<ans<<endl;
		
	}
	return 0;
}

C++: #include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>

using namespace std;
using vec = vector<int>;
using mat = vector<vec>;
using lst = list<int>;


bool solve()
{
	int T, D, L;
	cin >> T >> D >> L;

	if (T == 0)return false;

	vec Wet(T, 0);

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

		if (x < L) { continue; }

		Wet[i] += 1;
		if (i + D < T)
		{
			Wet[i + D] -= 1;
		}
	}

	int ans = Wet[0] != 0;

	for (int i = 1; i < T-1; ++i)
	{
		Wet[i] += Wet[i - 1];
		ans += Wet[i] != 0;
	}
	
	cout << ans << endl;

	return true;
}


int main()
{
	while(solve());

	return 0;
}

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

int t, d, l;
vector<int> x;

int solve();

int main() {
  while(1) {
    cin >> t >> d >> l;
    if(t + d + l == 0) break;
    x.assign(t, 0);
    for(int i = 0; i < t; ++i) cin >> x[i];
    cout << solve() << endl;
  }

  return 0;
}

int solve() {
  int ans = 0, lim = -1;
  for(int i = 0; i < t; ++i) {
    if(lim >= i) ++ans;
    if(x[i] >= l) lim = i + d;
  }
  return ans;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    vector<int> ans;
    int T, D, L;
    while(true){
        int res = 0;
        cin >> T >> D >> L;
        if(T == 0) break;
        int wet = 0;
        rep(i, T){
            if(wet > 0) res++;
            int x; cin >> x;
            if(L <= x) wet = D;
            else wet--;
        }
        ans.push_back(res);
    }
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)

int main(void){
    int T,D,L;
    while(cin>>T>>D>>L,T|D|L){
        vector<int> imos(T+D);
        rep(i,T){
            int x;
            cin>>x;
            if(x>=L)imos[i]++,imos[i+D]--;
        }
        int res=0;
        rep(i,T-1){
            imos[i+1]+=imos[i];
            if(imos[i]>0)res++;
        }
        cout<<res<<endl;
    }
    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 x,cnt=0,flag=0;;
  for(int i=0;i<t;++i) {
    cin >> x;
    if(flag){
      flag--; cnt++;
    }
    if(x>=l)flag=d;
  }
  cout << cnt << endl;
  }
  
  return 0;
}