'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n));
  const A = s[0];
  const B = s[1];
  const C = s[2];
  const D = s[3];

  const status = [...Array(101)].fill(0);

  for (let i = A + 1; i <= B; i++) {
    status[i] += 1;
  }

  for (let i = C + 1; i <= D; i++) {
    status[i] += 1;
  }

  const answer = status.filter(n => n === 2).length;
  console.log(answer);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
