"use strict";
    
const main = arg => {
    const times = arg.split("\n")[0].split(" ");
  	let start = Math.max(times[0],times[2]);
  	let end = Math.min(times[1],times[3]);
  	let ans = 0;
  	end - start > 0? ans = end - start:'';
    console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
