"use strict";    
const main = arg => {
  	const Nums = arg.split("\n")[0].split(" ");
	const AliceMin = Nums[0]*1;
  	const AliceMax = Nums[1]*1;
   	const BobMin = Nums[2]*1;
   	const BobMax = Nums[3]*1;
  	let ans = 0;
  	// 部分的に被っているパターン
	if((AliceMax > BobMin) && (BobMax > AliceMax)){
    	ans = AliceMax - BobMin;
    } else if((AliceMax > BobMin) && (BobMax > AliceMax)){
    	ans = BobMax - BobMin;
    } else if((AliceMin < BobMin) && (BobMax < AliceMax)) {
      	ans = BobMax - BobMin;
    }
  
  	console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
