function main(input){
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  var l = [];
  var r = [];
    
  for (var i = 0; i < m; i++) {
    l[i] = parseInt(input[i+1].split(" ")[0]);
    r[i] = parseInt(input[i+1].split(" ")[1]);
  }

  lmax = Math.max.apply(null,l);
  rmin = Math.min.apply(null,r);

  var answer = (rmin - lmax +1)>0 ? (rmin - lmax +1) : 0 ;
  console.log(answer);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));