'use strict';
function Main(stdin){
  const [A, B, C, D] = stdin.trim().split(' ').map(str => Number(str));
  
  let start =  A < C ? C : A;
  let end = B < D ? B : D;
  let result = end < start ? 0 : end - start;
  console.log(result);
}

// 固定
Main(require("fs").readFileSync("/dev/stdin", "utf8"));