#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
const int MaxN=3100;

int N,P,L,Lb;
int a[MaxN],p[MaxN],d[MaxN];
int f[MaxN][MaxN],g[MaxN][MaxN];

void prep(){
	memset(p,0,sizeof(p));
	memset(d,0,sizeof(d));	
	int prepis=0,lnow=0;
	for (int i=1; i<=N; i++){		
		if (lnow>prepis) d[i]=P;
		lnow+=a[i];
		p[i]=P;
		while (lnow>prepis+P){
			prepis+=P; 
			p[i]+=P;
		}
		if (lnow>=prepis+P) prepis+=P;
	}
	Lb=L;
	if (lnow>prepis && L%P>=lnow-prepis) Lb=L+P-L%P;
}

void dp(){
	memset(f,1,sizeof(f));
	memset(g,1,sizeof(g));
	for (int i=0; i<=N; i++) f[i][0]=0;
	
	for (int i=1; i<=N; i++)
		for (int j=1; j<=i; j++){
			f[i][j]=f[i-1][j];
			f[i][j]=min(f[i][j],f[i-1][j-1]+p[i]);
			f[i][j]=min(f[i][j],g[i-1][j-1]+p[i]-d[i]);			
			g[i][j]=min(f[i-1][j-1]+p[i], g[i-1][j-1]+p[i]-d[i]);
		}
	int rst=0;	
	for (int j=1; j<=N; j++)
		if (f[N][j]<=L || g[N][j]<=Lb) rst=j;			
		
	printf("%d\n",rst);
}

int main(){
	while (scanf("%d%d%d",&N,&P,&L)!=EOF){
		if (N==0 && P==0 && L==0) break;
		for (int i=1; i<=N; i++) scanf("%d",a+i);
		prep();
		dp();
	}
	return 0;
}
