function Main(input) {
	var input = input.split(" ");
  	input = input.map(function (element) { return Number(element); });
  	var n=0;
	for(i=input[0];i<=input[1];i++){
      if(i>=input[2]&&i<=input[3]){        
        n++;
      }
    }
	if(n!==0){
	  n--;
  	}
      console.log(n);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));