main = do
  getLine
  cards <- map (map read . words) . lines <$> getContents
  let l = map head cards
  let r = map (!! 1) cards
  let diff = (minimum r) - (maximum l)
  print $ if diff >= 0 then diff + 1 else 0