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;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll t,d,l;

void solve(){
    vector<ll> x(t+10,0);

    vector<int> imos(t+d+10,0);
    rep(i,t){
        int x; cin >> x;
        if(x>=l){
            int ti = i+1;
            imos[ti]++;
            imos[ti+d]--;
        }
    }
    rep(i,t) imos[i+1] += imos[i];
    int ans = 0;
    for(int i=1;i<t;i++){
        if(imos[i]>0) ans++;
    }
    cout << ans << endl;
}

int main(){
    while(cin>>t>>d>>l){
        if(!t && !d && !l) break;
        solve();
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int t,d,l;
	while(cin >> t >> d >> l)
	{
		if(t==0) break;

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

C++: #include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;

void solve() {
	ll T, D, L; scanf("%lld %lld %lld", &T, &D, &L); if (T == 0 and D == 0 and L == 0) exit(0);
	vector<ll> x(T); for (int i = 0; i < T; i++) scanf("%lld", &x[i]);
	ll res = 0;
	vector<ll> time(300000);
	for (int i = 1; i <= T; i++) {
		if (x[i - 1] >= L) {
			time[i]++;
			time[i + D]--;
		}
	}
	for (int i = 1; i <= T; i++) time[i + 1] += time[i];
	for (int i = 1; i < T; i++) res += time[i] > 0;
	printf("%lld\n", res);
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/

	int kkt = 89;
	while (kkt) {
		solve();
	}
	return 0;
}

C++: 

#include <stdio.h> int main(){ int T,D,L; for(;~scanf("%d%d%d",&T,&D,&L)&&T&&D&&L;){ int r=0; for(int i=0,x,y=0;i<T;i++){ if(--y>=0)r++; scanf("%d",&x); if(x>=L)y=D; } printf("%d\n",r); } }

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

using namespace std;

using lint = long long;
using ldouble = long double;

bool solve() {
    int T, D, L;
    cin >> T >> D >> L;
    if (T == 0) return false;

    int prev = -D - 1, ans = 0;
    for (int t = 0; t < T; ++t) {
        if (t - prev <= D) ++ans;

        int x;
        cin >> x;
        if (x >= L) prev = t;
    }

    cout << ans << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}

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

int main(){
  int T, D, L;
  while(cin >> T >> D >> L, T){
    vector<int> X(T), A(T+D+1,0);
    for(int i = 0; i < T; ++i) cin >> X[i];
    for(int i = 0; i < T; ++i){
      if(X[i] >= L){
        ++A[i];
        --A[i+D];
      }
    }
    int ans = 0;
    for(int i = 0; i < T-1; ++i){
      A[i+1] += A[i];
      if(A[i] > 0){
        //cerr << "#" << i << endl;
        ++ans;
      }
    }
    cout << ans << endl;
  }
}

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

#define INF ((int)1e9)
int main(){
  int T, D, L;

  for(;;){
    int X, ans = 0;
    cin>>T>>D>>L;

    if(!T&&!D&&!L) break;

    for(int i = 0, num = INF; i < T-1; i++, num++){
      cin>>X;
      if(X >= L) num = 0;
      if(num < D) ans++;
    }

    cin>>X;

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