function Main(input) {
2.	var tmp = input.split(" ");
3.	var a = parseInt(tmp[0], 10);
4.	var b = parseInt(tmp[1], 10);
5.	var c = parseInt(tmp[2], 10);
6.	var d = parseInt(tmp[3], 10);
7.        if(b < c) {
8.            //   a   b   c  d
9.           console.log("%d", 0);
10.        } else {
11.            if( b < d) { 
12.              //   a  c  b  d
13.              console.log("%d", b - c );
14.            }  else  {
15.             //  a  c  d   b 
16.              console.log("%d",  d - c);
17.           }
18.        }
19.}
20.Main(require("fs").readFileSync("/dev/stdin", "utf8"));
