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;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for(long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for(long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                                                            \
    (upper_bound((V).begin(), (V).end(), X) -                                  \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                                                               \
    {                                                                          \
        cerr << #v << ':';                                                     \
        for(auto xv : v) cerr << xv << ' ';                                    \
        cerr << endl;                                                          \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T &a, const T &b) {
    if(a > b) a = b;
    return a > b;
}
template <typename T> inline bool chmax(T &a, const T &b) {
    if(a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* liblary */

/* main */

void solve(ll T, ll D, ll L) {
    ll x;
    ll last = 0;
    bool wet[T + D + 201900] = {0};
    FOR(i, 0, T) {
        cin >> x;
        if(L <= x) {
            FOR(j, 0, D) {
                wet[i + j] = true;
                if(i + j < last) j = last - i;
                last = i + j;
            }
        }
    }
    ll ans = 0;
    FOR(i, 0, T - 1) ans += wet[i];
    cout << ans << endl;
}

signed main() {
    ll T, D, L;
    while(true) {
        cin >> T >> D >> L;
        if(!T && !D && !L) return 0;
        solve(T, D, L);
    }
}

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

signed main(){
	int t,d,l;
	while(cin >> t >> d >> l,t){
		int ans = 0,cnt = 0;
		for(int i = 0;i < t;i++){
			int x;
			cin >> x;
			if(x >= l) cnt = d;
			if(cnt && i != t - 1){
				ans++;
				cnt--;
			}
		}
		cout << ans << endl;
	}
}

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

#define dump(a) cerr << #a << " " << a << endl
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using vi = vector<int>;

int main(){
  int t, d,l;
  while(cin >> t >> d>>l, t){
    vector<int> x(t);
    vector<int> xx(t+100010,0);
    rep(i,t){
        cin>>x[i];
        if(x[i]>=l){
            xx[i+1]+=1;
            xx[i+d+1]-=1;
        }else{
            //xx[i]=0;
        }
        if(i!=0)xx[i]+=xx[i-1];
    }
    int ans=0,bf=0;
    rep(i,t){
        if(xx[i]){
            ans+=1;
        }
    }
    cout<<ans<<endl;
  }
}

C++: #include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int T,D,L;
    while(1){
        cin>>T>>D>>L;
        if(T==0)break;
        int ans=0,a,last=-1e9;
        for(int i=0;i<T;i++){
        if( i-last <=D ){
            ans++;
        }
        cin>>a;
        if(a>=L)last=i;
        }
        cout<<ans<<endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;

int main(){
    int t, d, l, x;
    while(cin >> t >> d >> l, t+d+l){
        int rest = 0, ans = 0;
        while(t-- > 0){
            cin >> x;
            if(x >= l)  rest = d;
            if(rest > 0){
                ans++;
                rest--;
            }
        }
        cout << max(ans-1, 0) << endl;
    }
    return 0;
}