#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[100],n,x,i,sum;
    sum = 0;
    scanf("%d%d",&n,&x);
    for(i = 0; i<n; i++)
        scanf("%d",&a[i]);
    for(i = 0; i<n-1; i++)
    {
        while(a[i]+a[i+1]>x)
        {
            a[i+1]--;
            sum++;
        }
    }
    printf("%d",sum);
    return 0;
}
