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;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

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 dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int t, d, l;

void solve() {
	vl v(t);
	ll ans = 0;
	ll cnt = 0;
	rep(i, t) {
		cin >> v[i];
		if (v[i] >= l) {
			cnt = d;
		}

		if (cnt > 0&&i!=t-1)ans++;
		cnt--;
	}
	cout << ans << endl;
}

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

	while (cin >> t >> d >> l,t) {
		solve();
	}
}

C++: #include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

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

C++: #include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;

int main()
{
    int T, D, L, wave, cnt, global_max, current_max;
    for (; ; ) {
        scanf("%d %d %d", &T, &D, &L);
        if (T == 0 && D == 0 && L == 0) break;
        cnt = global_max = current_max = 0;
        for (int i = 0; i < T; i++) {
            scanf("%d", &wave);
            if (wave >= L) {
                if (cnt < 0) current_max = 1;
                else current_max++;
                cnt = D;
            }
            else {
                cnt--;
                if (cnt > 0) current_max++;
                if (cnt == 0) global_max = max(global_max, current_max);
            }
        }
        if (current_max > 0) global_max = max(global_max, current_max-1);
        printf("%d\n", global_max);
    }

    return 0;
}

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

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

    int t, d, l;
    while (cin >> t >> d >> l) {
        if (t == 0) break;
        int last = -1e9;
        int cnt = 0;
        for (int i = 0; i < t; i++) {
            int a;
            cin >> a;
            if (i == t - 1) continue;
            if (a >= l) {
                last = i;
                cnt++;
            } else if (i - last < d) cnt++;
        }
        cout << cnt << '\n';
    }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
#define MAX_N 10000000
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t, d, l;
	while(cin >> t >> d >> l, t | d | l)
	{
		int cnt = 0;
		int b = -MAX_N;
		for(int i = 0; i < t; i++)
		{
			int x;
			cin >> x;
			if(i + 1 == t)
				continue;
			if(x >= l){
				b = i;
			}
			cnt += i - b<d;
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

void solve(int t, int d, int l)
{
    VI x(t);
    rep(i, t) cin >> x[i];
    int ans = -1;
    int cur = 0;
    int remain = 0;
    rep(i, t)
    {
        if (x[i] >= l)
        {
            cur++;
            remain = d - 1;
        }
        else
        {
            if (remain > 0)
            {
                cur++;
            }
            remain--;
        }
        chmax(ans, cur);
    }
    if (ans > 0)
        ans--;
    cout << ans << endl;
}

int main()
{
    int t, d, l;
    while (cin >> t >> d >> l, t)
    {
        solve(t, d, l);
    }

    return 0;
}