"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let A = xs[0];
   let B = xs[1];
   let C = xs[2];
   let D = xs[3];
   let ans = 0;
   
   if(B<C){
    ans = 0;
   }else if(A < C && B < D){
    ans = B - C;
   }else if(C < A && B < D){
    ans = B - A;
   }else if(A < C && D < B){
    ans = D - C;
   }else if(C < A && D < B){
    ans = D - A;
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));


