import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto ip = readln.split.to!(int[]), N=ip[0], M=ip[1];
	int L = 0;
	int R = N;
  
	foreach(i; 0..M){
		auto LR = readln.split.to!(int[]);
		L = max(L, LR[0]);
		R = min(R, LR[1]);
		if(L==R||L>R) break;
	}
	if(L==R||L>R)) writeln(1);
	else writeln(R-L+1);
}