sAdd :: [String] -> Int -> Int
sAdd [] acc = acc
sAdd src acc = sAdd (tail src) acc'
  where
    cs = words (head src)
    l = read (head cs)
    r = read (last cs)
    acc' = acc + r  + (-l) + 1

main = do
  ns <- lines <$> getContents
  putStrLn $ show $ sAdd (tail ns) 0