import java.util.*;

public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abcd = new int[4];
		for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		}
		int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2];
		int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3];
		System.out.println(cd - ab > 0 ? cd - ab : 0);
	}
} import java.util.*; util.* java public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abcd = new int[4];
		for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		}
		int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2];
		int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3];
		System.out.println(cd - ab > 0 ? cd - ab : 0);
	}
} Main public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abcd = new int[4];
		for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		}
		int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2];
		int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3];
		System.out.println(cd - ab > 0 ? cd - ab : 0);
	} main {
		Scanner sc = new Scanner(System.in);
		int[] abcd = new int[4];
		for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		}
		int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2];
		int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3];
		System.out.println(cd - ab > 0 ? cd - ab : 0);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] abcd = new int[4]; abcd new int[4] 4 for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
			abcd[i] = sc.nextInt();
		} {
			abcd[i] = sc.nextInt();
		} abcd[i] = sc.nextInt() abcd[i] abcd i sc.nextInt() sc.nextInt sc int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2]; ab abcd[0] > abcd[2] ? abcd[0] : abcd[2] abcd[0] > abcd[2] abcd[0] abcd 0 abcd[2] abcd 2 abcd[0] abcd 0 abcd[2] abcd 2 int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3]; cd abcd[1] < abcd[3] ? abcd[1] : abcd[3] abcd[1] < abcd[3] abcd[1] abcd 1 abcd[3] abcd 3 abcd[1] abcd 1 abcd[3] abcd 3 System.out.println(cd - ab > 0 ? cd - ab : 0) System.out.println System.out System System.out cd - ab > 0 ? cd - ab : 0 cd - ab > 0 cd - ab cd ab 0 cd - ab cd ab 0 String[] args args public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abcd = new int[4];
		for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		}
		int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2];
		int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3];
		System.out.println(cd - ab > 0 ? cd - ab : 0);
	}
} public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abcd = new int[4];
		for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		}
		int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2];
		int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3];
		System.out.println(cd - ab > 0 ? cd - ab : 0);
	}
} Main
import java.util.*;

public class Main {

	public static void main(
			String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] abcd = new int[4];
		for (int i = 0; i < 4; i++) {
			abcd[i] = sc.nextInt();
		}
		int ab = abcd[0] > abcd[2] ? abcd[0] : abcd[2];
		int cd = abcd[1] < abcd[3] ? abcd[1] : abcd[3];
		System.out.println(cd - ab > 0 ? cd - ab : 0);
	}
}
