"use strict";

function main(input) {
  input = input.split(" ");
  input[0] = parseInt(input[0]);
  input[1] = parseInt(input[1]);
  input[2] = parseInt(input[2]);
  input[3] = parseInt(input[3]);
  let a;
  let b;
  if (input[1] > input[3]) {
    a = input[3];
  } else {
    a = input[1];
  }
  if (input[0] > input[2]) {
    b = input[0];
  } else {
    b = input[2];
  }
  if (a > b) {
    console.log(String(Math.abs(b - a)));
  } else {
    console.log("0");
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf-8"));
