function Main(input) {
	tmp = input.split("\n");
	a = tmp[0].split(" ");
	var n = parseInt(a[0]);
	var m = parseInt(a[1]);
	var rl = 0;
	var rr = 0;
	var r = 0;
	
	for (var i = 1 ; i <= m ; i++){
		var b = tmp[i].split(" ");
		var bl = parseInt(b[0]);
		var br = parseInt(b[1]);
		if(i == 1){
			rl = bl;
			rr = br;
		}else{
			if(rl <= bl){
				rl = bl;
			}
			if(rr >= br){
				rr = br;
			}
		}
	}
	r = rr - rl + 1;
	console.log(r);
}

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