import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int aStart = sc.nextInt();
		int aEnd = sc.nextInt();
		int bStart = sc.nextInt();
		int bEnd = sc.nextInt();
		sc.close();

		int start = aStart > bStart ? aStart : bStart;
		int end = aEnd > bEnd ? bEnd : aEnd;

		int answer = end - start;

		if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		}

	}

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

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int aStart = sc.nextInt();
		int aEnd = sc.nextInt();
		int bStart = sc.nextInt();
		int bEnd = sc.nextInt();
		sc.close();

		int start = aStart > bStart ? aStart : bStart;
		int end = aEnd > bEnd ? bEnd : aEnd;

		int answer = end - start;

		if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		}

	}

} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int aStart = sc.nextInt();
		int aEnd = sc.nextInt();
		int bStart = sc.nextInt();
		int bEnd = sc.nextInt();
		sc.close();

		int start = aStart > bStart ? aStart : bStart;
		int end = aEnd > bEnd ? bEnd : aEnd;

		int answer = end - start;

		if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		}

	} main {

		Scanner sc = new Scanner(System.in);
		int aStart = sc.nextInt();
		int aEnd = sc.nextInt();
		int bStart = sc.nextInt();
		int bEnd = sc.nextInt();
		sc.close();

		int start = aStart > bStart ? aStart : bStart;
		int end = aEnd > bEnd ? bEnd : aEnd;

		int answer = end - start;

		if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		}

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int aStart = sc.nextInt(); aStart sc.nextInt() sc.nextInt sc int aEnd = sc.nextInt(); aEnd sc.nextInt() sc.nextInt sc int bStart = sc.nextInt(); bStart sc.nextInt() sc.nextInt sc int bEnd = sc.nextInt(); bEnd sc.nextInt() sc.nextInt sc sc.close() sc.close sc int start = aStart > bStart ? aStart : bStart; start aStart > bStart ? aStart : bStart aStart > bStart aStart bStart aStart bStart int end = aEnd > bEnd ? bEnd : aEnd; end aEnd > bEnd ? bEnd : aEnd aEnd > bEnd aEnd bEnd bEnd aEnd int answer = end - start; answer end - start end start if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		} aEnd < bStart || bEnd < aStart aEnd < bStart aEnd bStart bEnd < aStart bEnd aStart {
			System.out.println("0");
		} System.out.println("0") System.out.println System.out System System.out "0" {
			System.out.println(answer);
		} System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int aStart = sc.nextInt();
		int aEnd = sc.nextInt();
		int bStart = sc.nextInt();
		int bEnd = sc.nextInt();
		sc.close();

		int start = aStart > bStart ? aStart : bStart;
		int end = aEnd > bEnd ? bEnd : aEnd;

		int answer = end - start;

		if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		}

	}

} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int aStart = sc.nextInt();
		int aEnd = sc.nextInt();
		int bStart = sc.nextInt();
		int bEnd = sc.nextInt();
		sc.close();

		int start = aStart > bStart ? aStart : bStart;
		int end = aEnd > bEnd ? bEnd : aEnd;

		int answer = end - start;

		if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		}

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int aStart = sc.nextInt();
		int aEnd = sc.nextInt();
		int bStart = sc.nextInt();
		int bEnd = sc.nextInt();
		sc.close();

		int start = aStart > bStart ? aStart : bStart;
		int end = aEnd > bEnd ? bEnd : aEnd;

		int answer = end - start;

		if (aEnd < bStart || bEnd < aStart) {
			System.out.println("0");
		} else {
			System.out.println(answer);
		}

	}

}