main = do
  [n,x] <- fmap (map read . words) getLine :: IO [Int]
  as <- fmap (map read . words) getLine :: IO [Int]
  let f [_] = 0
      f (a:b:as) = y + f (((b-y)`max`1):as)
        where y = (a+b-x)`max`0
  print $ f as