function Main(input){
	var tmp = input.split(" ");
	var num1 = Math.max(tmp[0], tmp[2]);
	var num2 = Math.min(tmp[1], tmp[3]);

	if(num2 < num1){
		console.log(0);
	}else{
		console.log(num2 - num1);
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));