#include<stdio.h>

using namespace std;

const int MAXN=1000000;

int a[MAXN];
int n,k;

int main()
{
    FILE *f,*g;
    f=fopen("zetoni.in","r");
    g=fopen("zetoni.out","w");
    fscanf(f,"%d %d",&n,&k);
    for(int i=0; i<n; i++)  
    {
            fscanf(f,"%d",&a[i]);
            a[i]=k-a[i];        
    }   
    int s=a[0];
    for(int i=1; i<n; i++)
    {
            if(a[i]>a[i-1]) s+=a[i]-a[i-1];        
    }
    fprintf(g,"%d",s);
    fclose(f);
    fclose(g);
}
