#include<cstdio>
#include<algorithm>
using namespace std;
int n,i,j,p,k,kp,s;
int d[1005],v[1005];
int main()
{
freopen("efort.in","r",stdin);
freopen("efort.out","w",stdout);
scanf("%d %d",&n,&k);
for (i=1;i<=n;i++) scanf("%d",&d[i]);
p=0; j=0; s=0;
while (j<n)
{
kp=0;
while ((kp<k)&&(j<n))
{
j++;
kp=kp+d[j];
}
p=j;
if (kp>k)
{
for (i=1;i<=k;i++) v[i]=1,s++;
for (i=k+1;i<=kp;i++) v[i]=v[i-1]+v[i-2],s=s+v[i];
}
else s=s+kp;
}
printf("%d",s);
return 0;
}