import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numA = scan.nextInt();
		int numB = scan.nextInt();
		int numC = scan.nextInt();
		int numD = scan.nextInt();

		int start = Math.max(numA, numC);
		int end = Math.min(numB, numD);

		int delta = 0;

		if (start < end) {
			delta = end - start;
		}
		System.out.println(delta);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numA = scan.nextInt();
		int numB = scan.nextInt();
		int numC = scan.nextInt();
		int numD = scan.nextInt();

		int start = Math.max(numA, numC);
		int end = Math.min(numB, numD);

		int delta = 0;

		if (start < end) {
			delta = end - start;
		}
		System.out.println(delta);
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numA = scan.nextInt();
		int numB = scan.nextInt();
		int numC = scan.nextInt();
		int numD = scan.nextInt();

		int start = Math.max(numA, numC);
		int end = Math.min(numB, numD);

		int delta = 0;

		if (start < end) {
			delta = end - start;
		}
		System.out.println(delta);
	} main {

		Scanner scan = new Scanner(System.in);

		int numA = scan.nextInt();
		int numB = scan.nextInt();
		int numC = scan.nextInt();
		int numD = scan.nextInt();

		int start = Math.max(numA, numC);
		int end = Math.min(numB, numD);

		int delta = 0;

		if (start < end) {
			delta = end - start;
		}
		System.out.println(delta);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int numA = scan.nextInt(); numA scan.nextInt() scan.nextInt scan int numB = scan.nextInt(); numB scan.nextInt() scan.nextInt scan int numC = scan.nextInt(); numC scan.nextInt() scan.nextInt scan int numD = scan.nextInt(); numD scan.nextInt() scan.nextInt scan int start = Math.max(numA, numC); start Math.max(numA, numC) Math.max Math numA numC int end = Math.min(numB, numD); end Math.min(numB, numD) Math.min Math numB numD int delta = 0; delta 0 if (start < end) {
			delta = end - start;
		} start < end start end {
			delta = end - start;
		} delta = end - start delta end - start end start System.out.println(delta) System.out.println System.out System System.out delta String[] args args public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numA = scan.nextInt();
		int numB = scan.nextInt();
		int numC = scan.nextInt();
		int numD = scan.nextInt();

		int start = Math.max(numA, numC);
		int end = Math.min(numB, numD);

		int delta = 0;

		if (start < end) {
			delta = end - start;
		}
		System.out.println(delta);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numA = scan.nextInt();
		int numB = scan.nextInt();
		int numC = scan.nextInt();
		int numD = scan.nextInt();

		int start = Math.max(numA, numC);
		int end = Math.min(numB, numD);

		int delta = 0;

		if (start < end) {
			delta = end - start;
		}
		System.out.println(delta);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numA = scan.nextInt();
		int numB = scan.nextInt();
		int numC = scan.nextInt();
		int numD = scan.nextInt();

		int start = Math.max(numA, numC);
		int end = Math.min(numB, numD);

		int delta = 0;

		if (start < end) {
			delta = end - start;
		}
		System.out.println(delta);
	}
}
