main = do
  n <- readLn
  xss <- mapM (const $ fmap (map read . words) getLine) [1..n]
  print (solve xss)


solve :: [[Int]] -> Int
solve = foldr f 0
 where
   f [a,b] c | a < b     = c+b
             | otherwise = c