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;

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    for (;;) {
        int t, d, l; cin >> t >> d >> l;
        if (!t) break;

        bool dry = true;
        int todry = 0, ans = 0;
        rep(i, 0, t) {
            int h; cin >> h;
            if (i + 1 == t) break;
            if (h >= l) {
                dry = false;
                todry = d;
                ans++;
            } else if (!dry) {
                ans++;
            }
            if (todry) todry--;
            if (!todry) dry = true;
        }
        cout << ans << endl;
    }
}

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;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  int t,d,l;
  while(cin>>t>>d>>l,t){
	int sum=0;
	int stk=0;
	for(int i=0;i<t;i++){
	  int x;
	  cin>>x;
	  if(x>=l)stk=d;
	  if(stk>0&&i<t-1){
		stk--;
		sum++;
	  }
	}
	cout<<sum<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;

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 <iostream>
using namespace std;

int main(){
  int t,d,l;
  int set[40] = {0};
  int t_set[10000];
  int set_count = 0;
  int t_num;

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

    for(int i = 0; i < t; i++){ cin >> t_set[i]; }

    for(int j = 0; j < t; j++){
      if(t_set[j] >= l){
        if(t_num == 0){
          if(j+d < t) set[set_count] += d;
          else set[set_count] += t-j-1;
          t_num = d-1;
        }
        else{
          set[set_count] -= t_num;
          set[set_count] += d;
          t_num = d-1;
        }
      }
      else if(t_num != 0){ t_num--; }

    }

    set_count++;
  }

  for(int t = 0; t < set_count; t++){
    cout << set[t] << endl;
  }

  return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){
	while(1){
		int t, d, l; cin >> t >> d >> l;
		if(!t && !d && !l) break;

		int ans = 0, last_time = 0;
		for(int i=0; i<t; i++){
			int x; cin >> x;
			if(x >= l) last_time = d;
			if(last_time > 0){
				ans++;
				last_time--;
			}
		}
		if(ans != 0) ans--;
		cout << ans << endl;
	}
}

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 ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B &b) { if (a<b) {a = b; return 1;} return 0;}
template<typename A, typename B> inline bool chmin(A &a, B &b) { if (a>b) {a = b; return 1;} return 0;}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;

int main() {
	int T, D, L;
	while (cin >> T >> D >> L, T || D || L) {
		int prevt = -1;
		int ans = 0;
		REP(i, T) {
			int x;
			scanf("%d", &x);
			if (x >= L) {
				if (prevt == -1) prevt = i;
				else {
					ans += min(i - prevt, D);
					prevt = i;
				}
			}
		}
		if (prevt != -1) ans += min(T - 1 - prevt, D);
		if (debug) printf("@ ");
		cout << ans << endl;
	}
	return 0;
}