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;

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

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

C++: #include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>
#include <string>

using namespace std;

void solve();

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

void solve() {
    while(1) {
        int t,d,l;
        cin >> t >> d >> l;
        if(t == 0 && d == 0 && l == 0) break;
        int x[t];
        for(int i = 0; i < t; i++) {
            cin >> x[i];
        }
        int sum = 0;
        int let = 0;
        for(int i = 0; i < t; i++) {
            if(let != 0) sum++;
            let--;
            if(let == -1) let = 0;
            if(x[i] >= l) let = d;
        }
        cout << sum << endl;
    }
}

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

using i64 = int64_t;

int main(){
    int t, d, l;
    while(cin >> t >> d >> l, t != 0){
        bool is_wet = false;
        int cnt = 0, ans = 0;
        for(int i=0;i<t;++i){
            if(is_wet)ans++;
            int x;
            cin >> x;
            if(x >= l){
                is_wet = true;
                cnt = 0;
            }else{
                cnt++;
            }
            if(cnt >= d)is_wet = false;
        }
        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)break;

        int ans=0;
        int dtime=0;
        for(int i=0;i<T;i++){
            
            int x;  cin>>x;

            if(dtime){
                ans++;
                dtime--;
            }
            if(L<=x){
                dtime=D;
            }

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

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

using namespace std;

int func(int t,int d,int l){
	int res = 0;
	int rem = -1;
	for(int i=0;i<t;++i){
		if(rem>=0){
			++res;
		}
		int x;
		cin >> x;
		if(l<=x){
			rem = d;
		}
		--rem;
	}
	return res;
}

int main(){
	int t,d,l;
	while(cin>>t>>d>>l){
		if(t==0)break;
		cout << func(t,d,l) << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define lps(i,j,n) for(int i=j;i<n;i++)
#define lp(i,n) lps(i,0,n)
#define DEKAI 1000000007
#define INF (1<<28)
#define int long long

signed main(){
  while(1){
    int t,d,l;
    cin>>t>>d>>l;
    if(t==0&&d==0&&l==0) break;
    int stat=INF,ans=0;
    lps(i,1,t+1){
      if(stat<d) ans++;
      int a;
      cin>>a;
      if(a>=l) stat=0;
      else stat++;
      // cout<<stat<<endl;
    }
    cout<<ans<<endl;
  }
  return 0;
  
}

C++: #pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
while(1){
int T,D,L;
cin>>T>>D>>L;
if(T==0)return 0;
V<int> dat(T);
for(int i=0;i<T;i++)cin>>dat[i];
int ans=0;
int place=0;
for(int i=0;i<T;i++){
  if(place){
    ans++;
    place--;
  }
  if(dat[i]>=L)place=D;
}
cout<<ans<<"\n";
}
}

C++: #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
const int DX[8]={-1,0,1,0,-1,-1,1,1},DY[8]={0,-1,0,1,-1,1,-1,1};


int main(){;
	while(1){
		int n,m,x;
		cin>>n>>m>>x;
		if(n==0) break;
		vi a(n-1);
		for(int i=0;i<n;i++){
			int y;
			cin>>y;
			if(y>=x){
				if(i<n-1) a[i]++;
				if(i+m<n-1) a[i+m]--;
			}
		}
		int res=0;
		for(int i=1;i<n-1;i++) a[i]+=a[i-1];
		for(auto i:a) if(i) res++;
		cout<<res<<endl;
	}
}