program zetoni;
var
  n,k,i:longint;
  b:int64;
  a:array[1..1000000] of longint;
  f,g:text;

begin
  assign(f,'zetoni.in');
  reset(f);
  assign(g,'zetoni.out');
  rewrite(g);
  readln(f,n,k);
  for i:=1 to n do
    read(f,a[i]);
  b:=k-a[1];
  for i:=2 to n do
    if a[i]<a[i-1] then
      b:=b+a[i-1]-a[i];
  writeln(g,b);
  close(f);
  close(g);
end.
