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;

const int MAX_T=1e5+10;

int T,D,L,x,ans;
vector<int> cnt(MAX_T);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> T >> D >> L,T){
        for (int i=0;i<=T;++i) cnt[i]=0;
        for (int i=1;i<=T;++i){
            cin >> x;
            if (x<L) continue;
            ++cnt[i];
            if (i+D<=T) --cnt[i+D];
        }
        ans=0;
        for (int i=0;i<T-1;++i){
            cnt[i+1]+=cnt[i];
            if (cnt[i+1]) ++ans;
        }
        cout << ans << '\n';
    }
}

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

int solve(int T, int D, int L) {
    vector<int> A(T);
    vector<int> imos(300000);
    for (int i = 0; i < T; i++) {
        cin >> A[i];
    }
    
    for (int i = 0; i < T; i++) {
        if (L <= A[i]) {
            imos[i]++;
            imos[i+D]--;
        }
    }
    for (int i = 1; i < T; i++) {
        imos[i] += imos[i-1];
    }
    
    int ret = 0;
    for (int i = 0; i < T-1; i++) {
        if (imos[i] > 0) ret++;
    }

    return ret;
}

int main(void){
    int t, d, l;
    vector<int> ans;
    while (1) {
        cin >> t >> d >> l;
        if (!t && !d && !l) break;
        ans.push_back(solve(t, d, l));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
    
}

C++: #include<iostream>

using namespace std;

int main(void){

  int T, D, L;
  int i;
  int ans;
  int tap;

  while(1){
    cin >> T >> D >> L;
    if(T==0 && D==0 && L==0)
      break;
    int x[T];
    ans=0;
    tap=0;
    
    for(i=0; i<T; i++){
      cin >> x[i];
    }
    for(i=0; i<T-1; i++){
      if(x[i]>=L)
	tap=D;
      
      tap--;
      
      if(tap>=0)
	ans++;
    }
    cout << ans << endl; 
  }
  return 0;
}

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

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int main() {
	for (int T, D, L; cin >> T >> D >> L&&T;) {
		int t = 0;
		int ans = 0;
		rep(i, 0, T) {
			int x; cin >> x;
			if (i == T - 1)break;
			if (x >= L)t = D;
			if (t) {
				t--;
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
template <typename T> using V = vector<T>;

bool solve() {
    ll T, D, L;
    cin >> T >> D >> L;
    if(!(T + D + L)) return false;
    ll rest_w = 0;
    ll ans = 0;
    for(ll i = 0; i < T; i++) {
        if(rest_w > 0) {
            ans++;
            rest_w--;
        }
        ll x;
        cin >> x;
        if(L <= x) rest_w = D;
    }
    cout << ans << endl;
    return true;
}

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

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

using namespace std;

int solve(int, int, int);

int main()
{
	int T=1, D, L;
	int anser[40] = { 0 };
	int count = 0;

	for (int i = 0; T != 0; i++) {

		scanf("%d %d %d", &T, &D, &L);

		if (T != 0) {
			anser[i]=solve(T, D, L);
		}
		count++;
	}

	for (int i = 0; i < count-1; i++) {
		cout << anser[i] << endl;
	}
	
	return 0;
}

int solve(int T, int D, int L)
{
	int x[100000] = { 0 };
	int anser=0;
	int wet = 0;

	for (int i = 0; i < T; i++) {
		scanf("%d", &x[i]);
	}

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

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

		if (x[i] >= L) {
			wet = D;
		}

	}

	return anser;
}

C++: #include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int t,d,l;
    while(cin >> t >> d >> l){
        if(t + d + l == 0)break;
        vector<int>v(t);
        for(auto && e : v ) cin >> e;
        int ans = 0;
        int lim = 0;
        rep(i,t){
            if(v[i] >= l){
                ans += (i < lim);
                lim = i + d + 1;
            } else if(i < lim){
                ans++;
            }
        }
        cout << ans << endl;
    }
}

C++: #include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    while (1)
    {
        int t, d, l;
        cin >> t >> d >> l;
        if (t == 0)
            break;
        int ans = 0, last = 0;
        rep(i, t)
        {
            int x;
            cin >> x;
            if (last > 0)
                ans++, last--;
            if (x >= l)
                last = d;
        }
        cout << ans << endl;
    }
}