main=do
 [n,x]<-map read.words<$>getLine
 a<-map read.words<$>getLine
 print(f a x n 0)
  where f _ _ 1 k = k
        f a x n k | (a!!0)+(a!!1)>x = f ((if (a!!0)-x>0 then 0 else (x-(a!!0))):(drop 2 a)) x (n-1) (k+(a!!0)+(a!!1)-x)
                  | otherwise       = f (tail a) x (n-1) k