import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int[] alice = new int[101];
		int[] bob = new int[101];

		for (int i = a + 1; i <= b; i++) {
			alice[i] = 1;
		}
		for (int i = c + 1; i <= d; i++) {
			bob[i] = 1;
		}
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		}

		System.out.println(ans);

	}

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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int[] alice = new int[101];
		int[] bob = new int[101];

		for (int i = a + 1; i <= b; i++) {
			alice[i] = 1;
		}
		for (int i = c + 1; i <= d; i++) {
			bob[i] = 1;
		}
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		}

		System.out.println(ans);

	}

} Main public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int[] alice = new int[101];
		int[] bob = new int[101];

		for (int i = a + 1; i <= b; i++) {
			alice[i] = 1;
		}
		for (int i = c + 1; i <= d; i++) {
			bob[i] = 1;
		}
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		}

		System.out.println(ans);

	} main {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int[] alice = new int[101];
		int[] bob = new int[101];

		for (int i = a + 1; i <= b; i++) {
			alice[i] = 1;
		}
		for (int i = c + 1; i <= d; i++) {
			bob[i] = 1;
		}
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		}

		System.out.println(ans);

	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int c = scan.nextInt(); c scan.nextInt() scan.nextInt scan int d = scan.nextInt(); d scan.nextInt() scan.nextInt scan int[] alice = new int[101]; alice new int[101] 101 int[] bob = new int[101]; bob new int[101] 101 for (int i = a + 1; i <= b; i++) {
			alice[i] = 1;
		} int i = a + 1; int i = a + 1; i a + 1 a 1 i <= b i b i++ i++ i {
			alice[i] = 1;
		} {
			alice[i] = 1;
		} alice[i] = 1 alice[i] alice i 1 for (int i = c + 1; i <= d; i++) {
			bob[i] = 1;
		} int i = c + 1; int i = c + 1; i c + 1 c 1 i <= d i d i++ i++ i {
			bob[i] = 1;
		} {
			bob[i] = 1;
		} bob[i] = 1 bob[i] bob i 1 int ans = 0; ans 0 for (int i = 0; i <= 100; i++) {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i <= 100 i 100 i++ i++ i {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		} {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		} if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			} alice[i] == 1 && bob[i] == 1 alice[i] == 1 alice[i] alice i 1 bob[i] == 1 bob[i] bob i 1 {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int[] alice = new int[101];
		int[] bob = new int[101];

		for (int i = a + 1; i <= b; i++) {
			alice[i] = 1;
		}
		for (int i = c + 1; i <= d; i++) {
			bob[i] = 1;
		}
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		}

		System.out.println(ans);

	}

} public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int[] alice = new int[101];
		int[] bob = new int[101];

		for (int i = a + 1; i <= b; i++) {
			alice[i] = 1;
		}
		for (int i = c + 1; i <= d; i++) {
			bob[i] = 1;
		}
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		}

		System.out.println(ans);

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int[] alice = new int[101];
		int[] bob = new int[101];

		for (int i = a + 1; i <= b; i++) {
			alice[i] = 1;
		}
		for (int i = c + 1; i <= d; i++) {
			bob[i] = 1;
		}
		int ans = 0;
		for (int i = 0; i <= 100; i++) {
			if (alice[i] == 1 && bob[i] == 1) {
				ans++;
			}
		}

		System.out.println(ans);

	}

}