import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		}

		if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		}

	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		}

		if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		}

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		}

		if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		}

	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		}

		if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int C = sc.nextInt(); C sc.nextInt() sc.nextInt sc int D = sc.nextInt(); D sc.nextInt() sc.nextInt sc if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		} A > C A C {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		} int z = A; z A A = C A C C = z C z z = B z B B = D B D D = z D z if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		} B < C B C {
			System.out.println("0");
		} System.out.println("0") System.out.println System.out System System.out "0" if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		} B <= D B D {
			System.out.println(B - C);
		} System.out.println(B - C) System.out.println System.out System System.out B - C B C {
			System.out.println(D - C);
		} System.out.println(D - C) System.out.println System.out System System.out D - C D C String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		}

		if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		}

	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		}

		if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		}

	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		if(A > C) {
			int z = A;
			A = C;
			C = z;
			z = B;
			B = D;
			D = z;
		}

		if(B < C) {
			System.out.println("0");
		} else if(B <= D){
			System.out.println(B - C);
		} else {
			System.out.println(D - C);
		}

	}
}