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++: /**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int t, d, l;
    while(cin >> t >> d >> l) {
        if(t == 0 && d == 0 && l == 0) break;
        vector<int> x(t);
        rep(i, t) {
            cin >> x[i];
        }
        int ans = 0;
        int now = 0;
        rep(i, t) {
            if(x[i] >= l) now = d;
            else {
                -- now;
            }
            if(i != t - 1) {
                if(now > 0) ++ ans;
            }
        }
        cout << ans << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(void){
    int t,d,l,x;
    while (cin>>t>>d>>l) {
        if (t==0&&d==0&&l==0) {
            break;
        }
        int start,flag=0,count=d,ans=0;
        for (int i=1;i<=t;i++) {
            cin>>x;
            if (flag==0) {
                if (x>=l) {
                    start=i;
                    flag=1;
                }
            } else {
                if (x<l) {
                    count--;
                    if (count==0) {
                        ans+=(i-start);
                        count=d;
                        flag=0;
                    }
                } else {
                    count=d;
                }
                if (i==t) {
                    ans+=i-start;
                }
            }
        }
        cout<<ans<<endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int t,d,l;
    while(cin >>t >>d >>l,t){
        vector<int> s(t);
        rep(i,t){
            int x;
            cin >>x;
            if(x>=l){
                s[i]++;
                s[min(t-1,i+d)]--;
            }
        }
        rep(i,t-1) s[i+1] += s[i];

        int ans = 0;
        rep(i,t) ans += (s[i]>0);
        cout << ans << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	while(1){
		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++: #define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;
#define INF 1e+18
//#define int long long

signed main() {
	LL T, D, L;
	while (cin >> T >> D >> L, T) {
		int tim = 0;
		int ans = 0;
		for (int i = 0; i < T - 1; ++i) {
			int x;
			cin >> x;
			if (x >= L) {
				tim = D;
			}
			else {
				tim = max(0, tim - 1);
			}
			if (tim) {
				++ans;
			}
		}
		int d;
		cin >> d;
		cout << ans << endl;
	}

}

C++: #include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll t,d,l;
  while(cin>>t>>d>>l,t+d+l){
    ll ans=0;
    ll nokori=0;
    for(int i=0;i<t;i++){
      ll x;cin>>x;
      if(nokori>0)ans++;
      nokori--;
      if(l<=x)nokori=d;
      //cout<<nokori<<endl;

    }
    cout<<ans<<endl;
  }
  return 0;
}