'use strict'
function Main(input) {
    input = input.split("\n").map(str => {
      return str.split(' ').map(str => parseInt(str))
    })

    const N = input.shift()[0]

    let result = [...Array(N).keys()].map(i => ++i)
      
   input.map(arr => {
     let min = arr[0]; let max = arr[1]
     result = result.filter(num => min <=num && num <= max )
   })

    console.log(result.length)

}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))