main = do

2

  getLine

3

  cards <- map (map read . words) . lines <$> getContents

4

  let l = map head cards

5

  let r = map (!! 1) cards

6

  let diff = (minimum r) - (maximum l)

7

  print $ if diff >= 0 then diff + 1 else 0