#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int T,D,L,current,ans,pre_wet = BIG_NUM;

	while(true){
		scanf("%d %d %d",&T,&D,&L);
		if(T == 0 && D == 0 && L == 0)break;

		pre_wet = BIG_NUM;
		ans = 0;

		scanf("%d",&current);
		if(current >= L){
			pre_wet = 1;
		}

		for(int loop = 2; loop <= T; loop++){
			scanf("%d",&current);
			if(current >= L){
				if(pre_wet != BIG_NUM){
					ans += min(D,loop-pre_wet);
				}
				pre_wet = loop;
			}else{
				if(pre_wet+D == loop){
					ans += D;
					pre_wet = BIG_NUM;
				}
			}
		}

		if(pre_wet < T){
			ans += min(D,(T-pre_wet));
		}

		printf("%d\n",ans);
	}

   return 0;
}