var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}

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

function Main(input){
	input = input.split(' ');
	var a1 = toInt(input[0]);
	var a2 = toInt(input[1]);
	var b1 = toInt(input[2]);
	var b2 = toInt(input[3]);
	var ans = max(min(a2,b2) - max(a1,b1),0);
	console.log(ans);
}

