'use strict'
function Main(input) {
    let NumArr = input.split('\n');
  	let info = NumArr.shift();

  	// 下限の最大値を求める
  	let left = NumArr.map(x => {return x.split(' ')[0]});
  	let leftMax = Math.max(...left);
    
  	// 上限の最小値を求める
   	let right = NumArr.map(x => {return x.split(' ')[1]});
  	let rightMin = Math.min(...right);
  
  	// 答え
  	let ans = rightMin - leftMax + 1;
  	console.log(ans);
}


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