import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> [Int] -> Int
solve time [t] = time
solve time (t1:t2:ts) = result + solve time (t2:ts)
  where result = min time $ t2 - t1

main :: IO ()
main = do
  [n, t] <- map read . words <$> getLine
  ss <- readIntsLine
  print $ solve t ss