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 <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t, d, l;
    while (cin >> t >> d >> l, t + d + l) {
        int ans = 0;
        int prev = 0;
        bool use = false;
        REP(i, 0, t) {
            int x;
            cin >> x;
            if (x >= l) {
                if (!use) {
                    prev = i;
                }
                use = true;
                ans += min(i - prev, d);
                prev = i;
            }
        }
        dump(ans);
        if (use) {
            ans += min(t - prev - 1, d);
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int t, d, l;
  while (cin >> t >> d >> l, t) {
    vector<int> imos(t + d);
    for (int i = 0; i < t; ++i) {
      int x;
      cin >> x;
      if (x >= l) {
        imos[i] += 1;
        imos[i + d] -= 1;
      }
    }
    for (int i = 0; i + 1 < t + d; ++i) {
      imos[i + 1] += imos[i];
    }
    int res = 0;
    for (int i = 0; i < t - 1; ++i) {
      res += !!imos[i];
    }
    cout << res << '\n';
  }
}

C++: //#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
int main(void){

	while(1){
		bool flag=false;
		long long int t,d,l;
		long long int last=0;
		long long int first=0;
		long long int total=0;

		cin>>t>>d>>l;
		if(t==0&&d==0&&l==0){
			break;
		}
		vector<long long int> x(t+1);
		LFOR(i,1,t){
			cin>>x[i];
		}

		FOR(i,1,t){
			if(x[i]>=l){
				if(flag==false){
					first=i;
					last=i+d;
					flag=true;
				}else{
					last=i+d;
				}
			}
			if(last<=i&&flag==true){
				if(last>t){
					last=t;
				}
				total+=last-first;
				flag=false;
			}
		}

		if(flag){
			total+=t-first;
		}

		cout<<total<<endl;


	}

}

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

using namespace std;

typedef long long llint;

int main() {
  int t, d, l;
  while (cin >> t >> d >> l, t) {
    vector<int> x(t);
    for (int i = 0; i < t; i++) {
      cin >> x[i];
    }
    int ans = 0, cnt = 0;
    for (int i = 0; i < t; i++) {
      if (cnt > 0) ans++, cnt--;
      if (x[i] >= l) cnt = d;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int n,d,l;
    while(cin>>n>>d>>l,n){
        int a[n],ans=0,p=0;
        r(i,n)cin>>a[i];
        r(i,n-1){
            if(a[i]>=l)p=d;
            p--;
            if(p>=0)ans++;
        }
        cout<<ans<<endl;
    }
}

C++: #include<bits/stdc++.h>
#define inf 1<<29
#define linf (1e16)
#define eps (1e-8)
#define Eps (1e-12)
#define mod 1000000007
#define pi acos(-1.0)
#define phi (1.0+sqrt(5.0))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define pld(a) printf("%.10Lf\n",(ld)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main()
{
  int a,b,c;
  while(cin>>a && a){
    cin>>b>>c;
    int x,t = 0,ans = 0;
    FOR(i,0,a-1){
      cin>>x;
      if(c<=x)t = b;
      if(0<t)ans++;
      t--;
    }
    cin>>x;
    cout<<ans<<endl;
  }
  return 0;
}

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

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

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

int main(){
  while (true){
  	int T, D, L; scanf("%d%d%d",&T,&D,&L); int x, a=0, lv=0;
    if (T==0) break;
    if (T==1) {printf("0\n"); continue;}
    
    for(int i=0; i<T; i++){
      scanf("%d",&x);
      if (x>=L) lv = D;
      if (lv && (i!=T-1)){a++; lv--;}
    }
    printf("%d\n",a);
  }
}