import Control.Monad
import Data.List

main = do
    n <- readLn
    ls <- replicateM n (map read . words <$> getLine)
    print $ getsolve ls
    
getsolve :: [[Int]] -> Int
getsolve [] = 0
getsolve ls = (last ( head ls) - head (head ls) + 1) + getsolve ( tail ls)