import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int aliceStartTime = scan.nextInt();		
		int aliceStopTime = scan.nextInt();
		int bobStartTime = scan.nextInt();
		int bobStopTime = scan.nextInt();
		
		if(aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime){
			System.out.println("0");
		}else if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int aliceStartTime = scan.nextInt();		
		int aliceStopTime = scan.nextInt();
		int bobStartTime = scan.nextInt();
		int bobStopTime = scan.nextInt();
		
		if(aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime){
			System.out.println("0");
		}else if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		}
	}
} Main public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int aliceStartTime = scan.nextInt();		
		int aliceStopTime = scan.nextInt();
		int bobStartTime = scan.nextInt();
		int bobStopTime = scan.nextInt();
		
		if(aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime){
			System.out.println("0");
		}else if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		}
	} main {
		
		Scanner scan = new Scanner(System.in);
		
		int aliceStartTime = scan.nextInt();		
		int aliceStopTime = scan.nextInt();
		int bobStartTime = scan.nextInt();
		int bobStopTime = scan.nextInt();
		
		if(aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime){
			System.out.println("0");
		}else if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int aliceStartTime = scan.nextInt(); aliceStartTime scan.nextInt() scan.nextInt scan int aliceStopTime = scan.nextInt(); aliceStopTime scan.nextInt() scan.nextInt scan int bobStartTime = scan.nextInt(); bobStartTime scan.nextInt() scan.nextInt scan int bobStopTime = scan.nextInt(); bobStopTime scan.nextInt() scan.nextInt scan if(aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime){
			System.out.println("0");
		}else if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		} aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime aliceStartTime <= bobStartTime aliceStartTime bobStartTime aliceStopTime <= bobStartTime aliceStopTime bobStartTime bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime bobStartTime <= aliceStartTime bobStartTime aliceStartTime bobStopTime <= aliceStartTime bobStopTime aliceStartTime {
			System.out.println("0");
		} System.out.println("0") System.out.println System.out System System.out "0" if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		} bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime bobStartTime <= aliceStartTime bobStartTime aliceStartTime aliceStopTime <= bobStopTime aliceStopTime bobStopTime {
			System.out.println(aliceStopTime - aliceStartTime);
		} System.out.println(aliceStopTime - aliceStartTime) System.out.println System.out System System.out aliceStopTime - aliceStartTime aliceStopTime aliceStartTime if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		} aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime aliceStartTime <= bobStartTime aliceStartTime bobStartTime bobStopTime <= aliceStopTime bobStopTime aliceStopTime {
			System.out.println(bobStopTime - bobStartTime);
		} System.out.println(bobStopTime - bobStartTime) System.out.println System.out System System.out bobStopTime - bobStartTime bobStopTime bobStartTime if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		} aliceStartTime <= bobStartTime aliceStartTime bobStartTime {
			System.out.println(aliceStopTime - bobStartTime);
		} System.out.println(aliceStopTime - bobStartTime) System.out.println System.out System System.out aliceStopTime - bobStartTime aliceStopTime bobStartTime if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		} bobStartTime <= aliceStartTime bobStartTime aliceStartTime {
			System.out.println(bobStopTime - aliceStartTime);
		} System.out.println(bobStopTime - aliceStartTime) System.out.println System.out System System.out bobStopTime - aliceStartTime bobStopTime aliceStartTime {
			System.out.println("エラー");
		} System.out.println("エラー") System.out.println System.out System System.out "エラー" String[] args args public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int aliceStartTime = scan.nextInt();		
		int aliceStopTime = scan.nextInt();
		int bobStartTime = scan.nextInt();
		int bobStopTime = scan.nextInt();
		
		if(aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime){
			System.out.println("0");
		}else if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		}
	}
} public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int aliceStartTime = scan.nextInt();		
		int aliceStopTime = scan.nextInt();
		int bobStartTime = scan.nextInt();
		int bobStopTime = scan.nextInt();
		
		if(aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime){
			System.out.println("0");
		}else if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int aliceStartTime = scan.nextInt();		
		int aliceStopTime = scan.nextInt();
		int bobStartTime = scan.nextInt();
		int bobStopTime = scan.nextInt();
		
		if(aliceStartTime <= bobStartTime && aliceStopTime <= bobStartTime
				|| bobStartTime <= aliceStartTime && bobStopTime <= aliceStartTime){
			System.out.println("0");
		}else if(bobStartTime <= aliceStartTime && aliceStopTime <= bobStopTime){
			System.out.println(aliceStopTime - aliceStartTime);
		}else if(aliceStartTime <= bobStartTime && bobStopTime <= aliceStopTime){
			System.out.println(bobStopTime - bobStartTime);
		}else if(aliceStartTime <= bobStartTime){
			System.out.println(aliceStopTime - bobStartTime);
		}else if(bobStartTime <= aliceStartTime){
			System.out.println(bobStopTime - aliceStartTime);
		}else{
			System.out.println("エラー");
		}
	}
}