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