function Main(s) {
  var s = s.split("\n")[0].split(" ").map(e => e*1);
  var backet = new Array(101).fill(0);
  var cnt = 0;
  for(var i = s[0]; i <= s[1]; i++) backet[i]++;
  for(var i = s[2]; i <= s[3]; i++) backet[i]++;
  for(var i of backet) if(i === 2) cnt++;
  console.log(Math.max(cnt - 1, 0));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));