import Control.Monad

main :: IO ()
main = do
  n <- readLn :: IO Int
  ds <- concat <$> replicateM n (map read . words <$> getLine)  :: IO [Int]
  print $ solve ds

solve :: [Int] -> Int
solve [] = 0
solve (x:y:ys) = (y-x+1) + solve ys