function main(input) {
  input=input.trim();
  const a = parseInt(input.split(" ")[0], 10);
  const b = parseInt(input.split(" ")[1], 10);
  const c = parseInt(input.split(" ")[2], 10);
  const d = parseInt(input.split(" ")[3], 10);
  var arr=[a,b,c,d]
  arr.sort(function(a,b){
    if( a < b ) return -1;
    if( a > b ) return 1;
    return 0;
  });
  if(c<=b||d<=a){
    console.log(arr[2]-arr[1]);
  }else{
    console.log(0);
  }

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