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();
		int ans = 0;

		int max = Math.max(A, C);
		int min = Math.min(B, D);

		if (B < C || D < A) {
			ans = 0;
		} else {
			ans = max - min;
		}

		System.out.println( Math.abs(ans) );
	}
} 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();
		int ans = 0;

		int max = Math.max(A, C);
		int min = Math.min(B, D);

		if (B < C || D < A) {
			ans = 0;
		} else {
			ans = max - min;
		}

		System.out.println( Math.abs(ans) );
	}
} 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();
		int ans = 0;

		int max = Math.max(A, C);
		int min = Math.min(B, D);

		if (B < C || D < A) {
			ans = 0;
		} else {
			ans = max - min;
		}

		System.out.println( Math.abs(ans) );
	} main {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int ans = 0;

		int max = Math.max(A, C);
		int min = Math.min(B, D);

		if (B < C || D < A) {
			ans = 0;
		} else {
			ans = max - min;
		}

		System.out.println( Math.abs(ans) );
	} 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 int ans = 0; ans 0 int max = Math.max(A, C); max Math.max(A, C) Math.max Math A C int min = Math.min(B, D); min Math.min(B, D) Math.min Math B D if (B < C || D < A) {
			ans = 0;
		} else {
			ans = max - min;
		} B < C || D < A B < C B C D < A D A {
			ans = 0;
		} ans = 0 ans 0 {
			ans = max - min;
		} ans = max - min ans max - min max min System.out.println( Math.abs(ans) ) System.out.println System.out System System.out Math.abs(ans) Math.abs Math ans 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();
		int ans = 0;

		int max = Math.max(A, C);
		int min = Math.min(B, D);

		if (B < C || D < A) {
			ans = 0;
		} else {
			ans = max - min;
		}

		System.out.println( Math.abs(ans) );
	}
} 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();
		int ans = 0;

		int max = Math.max(A, C);
		int min = Math.min(B, D);

		if (B < C || D < A) {
			ans = 0;
		} else {
			ans = max - min;
		}

		System.out.println( Math.abs(ans) );
	}
} 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();
		int ans = 0;

		int max = Math.max(A, C);
		int min = Math.min(B, D);

		if (B < C || D < A) {
			ans = 0;
		} else {
			ans = max - min;
		}

		System.out.println( Math.abs(ans) );
	}
}