import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] num = sc.nextLine().split(" ");
		sc.close();
		int[] n = new int[4];
		for (int i = 0; i < 4; i++) {
			n[i] = Integer.parseInt(num[i]);
		}
		int start = Math.max(n[0], n[2]);
		int end = Math.min(n[1], n[3]);
		System.out.println(end > start ? end - start : 0);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] num = sc.nextLine().split(" ");
		sc.close();
		int[] n = new int[4];
		for (int i = 0; i < 4; i++) {
			n[i] = Integer.parseInt(num[i]);
		}
		int start = Math.max(n[0], n[2]);
		int end = Math.min(n[1], n[3]);
		System.out.println(end > start ? end - start : 0);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] num = sc.nextLine().split(" ");
		sc.close();
		int[] n = new int[4];
		for (int i = 0; i < 4; i++) {
			n[i] = Integer.parseInt(num[i]);
		}
		int start = Math.max(n[0], n[2]);
		int end = Math.min(n[1], n[3]);
		System.out.println(end > start ? end - start : 0);
	} main {
		Scanner sc = new Scanner(System.in);
		String[] num = sc.nextLine().split(" ");
		sc.close();
		int[] n = new int[4];
		for (int i = 0; i < 4; i++) {
			n[i] = Integer.parseInt(num[i]);
		}
		int start = Math.max(n[0], n[2]);
		int end = Math.min(n[1], n[3]);
		System.out.println(end > start ? end - start : 0);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] num = sc.nextLine().split(" "); num sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " sc.close() sc.close sc int[] n = new int[4]; n new int[4] 4 for (int i = 0; i < 4; i++) {
			n[i] = Integer.parseInt(num[i]);
		} int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
			n[i] = Integer.parseInt(num[i]);
		} {
			n[i] = Integer.parseInt(num[i]);
		} n[i] = Integer.parseInt(num[i]) n[i] n i Integer.parseInt(num[i]) Integer.parseInt Integer num[i] num i int start = Math.max(n[0], n[2]); start Math.max(n[0], n[2]) Math.max Math n[0] n 0 n[2] n 2 int end = Math.min(n[1], n[3]); end Math.min(n[1], n[3]) Math.min Math n[1] n 1 n[3] n 3 System.out.println(end > start ? end - start : 0) System.out.println System.out System System.out end > start ? end - start : 0 end > start end start end - start end start 0 String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] num = sc.nextLine().split(" ");
		sc.close();
		int[] n = new int[4];
		for (int i = 0; i < 4; i++) {
			n[i] = Integer.parseInt(num[i]);
		}
		int start = Math.max(n[0], n[2]);
		int end = Math.min(n[1], n[3]);
		System.out.println(end > start ? end - start : 0);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] num = sc.nextLine().split(" ");
		sc.close();
		int[] n = new int[4];
		for (int i = 0; i < 4; i++) {
			n[i] = Integer.parseInt(num[i]);
		}
		int start = Math.max(n[0], n[2]);
		int end = Math.min(n[1], n[3]);
		System.out.println(end > start ? end - start : 0);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] num = sc.nextLine().split(" ");
		sc.close();
		int[] n = new int[4];
		for (int i = 0; i < 4; i++) {
			n[i] = Integer.parseInt(num[i]);
		}
		int start = Math.max(n[0], n[2]);
		int end = Math.min(n[1], n[3]);
		System.out.println(end > start ? end - start : 0);
	}
}