import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A, B;
		int min,max;
		A = new int[2];
		B = new int[2];
		for(int i = 0; i < 2; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			B[i] = sc.nextInt();
		}

		if(A[1] <= B[0] || B[1] <= A[0]) {
			System.out.println(0);
			System.exit(0);
		}

		if(A[0] < B[0]) {
			min = B[0];
		}else {
			min = A[0];
		}

		if(A[1] < B[1]) {
			max = A[1];
		}else {
			max = B[1];
		}

		System.out.println(max - min);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A, B;
		int min,max;
		A = new int[2];
		B = new int[2];
		for(int i = 0; i < 2; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			B[i] = sc.nextInt();
		}

		if(A[1] <= B[0] || B[1] <= A[0]) {
			System.out.println(0);
			System.exit(0);
		}

		if(A[0] < B[0]) {
			min = B[0];
		}else {
			min = A[0];
		}

		if(A[1] < B[1]) {
			max = A[1];
		}else {
			max = B[1];
		}

		System.out.println(max - min);
		sc.close();
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A, B;
		int min,max;
		A = new int[2];
		B = new int[2];
		for(int i = 0; i < 2; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			B[i] = sc.nextInt();
		}

		if(A[1] <= B[0] || B[1] <= A[0]) {
			System.out.println(0);
			System.exit(0);
		}

		if(A[0] < B[0]) {
			min = B[0];
		}else {
			min = A[0];
		}

		if(A[1] < B[1]) {
			max = A[1];
		}else {
			max = B[1];
		}

		System.out.println(max - min);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int[] A, B;
		int min,max;
		A = new int[2];
		B = new int[2];
		for(int i = 0; i < 2; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			B[i] = sc.nextInt();
		}

		if(A[1] <= B[0] || B[1] <= A[0]) {
			System.out.println(0);
			System.exit(0);
		}

		if(A[0] < B[0]) {
			min = B[0];
		}else {
			min = A[0];
		}

		if(A[1] < B[1]) {
			max = A[1];
		}else {
			max = B[1];
		}

		System.out.println(max - min);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] A A B; B int min min max; max A = new int[2] A new int[2] 2 B = new int[2] B new int[2] 2 for(int i = 0; i < 2; i++) {
			A[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < 2 i 2 i++ i++ i {
			A[i] = sc.nextInt();
		} {
			A[i] = sc.nextInt();
		} A[i] = sc.nextInt() A[i] A i sc.nextInt() sc.nextInt sc for(int i = 0; i < 2; i++) {
			B[i] = sc.nextInt();
		} int i = 0; int i = 0; i 0 i < 2 i 2 i++ i++ i {
			B[i] = sc.nextInt();
		} {
			B[i] = sc.nextInt();
		} B[i] = sc.nextInt() B[i] B i sc.nextInt() sc.nextInt sc if(A[1] <= B[0] || B[1] <= A[0]) {
			System.out.println(0);
			System.exit(0);
		} A[1] <= B[0] || B[1] <= A[0] A[1] <= B[0] A[1] A 1 B[0] B 0 B[1] <= A[0] B[1] B 1 A[0] A 0 {
			System.out.println(0);
			System.exit(0);
		} System.out.println(0) System.out.println System.out System System.out 0 System.exit(0) System.exit System 0 if(A[0] < B[0]) {
			min = B[0];
		}else {
			min = A[0];
		} A[0] < B[0] A[0] A 0 B[0] B 0 {
			min = B[0];
		} min = B[0] min B[0] B 0 {
			min = A[0];
		} min = A[0] min A[0] A 0 if(A[1] < B[1]) {
			max = A[1];
		}else {
			max = B[1];
		} A[1] < B[1] A[1] A 1 B[1] B 1 {
			max = A[1];
		} max = A[1] max A[1] A 1 {
			max = B[1];
		} max = B[1] max B[1] B 1 System.out.println(max - min) System.out.println System.out System System.out max - min max min sc.close() sc.close sc String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A, B;
		int min,max;
		A = new int[2];
		B = new int[2];
		for(int i = 0; i < 2; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			B[i] = sc.nextInt();
		}

		if(A[1] <= B[0] || B[1] <= A[0]) {
			System.out.println(0);
			System.exit(0);
		}

		if(A[0] < B[0]) {
			min = B[0];
		}else {
			min = A[0];
		}

		if(A[1] < B[1]) {
			max = A[1];
		}else {
			max = B[1];
		}

		System.out.println(max - min);
		sc.close();
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A, B;
		int min,max;
		A = new int[2];
		B = new int[2];
		for(int i = 0; i < 2; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			B[i] = sc.nextInt();
		}

		if(A[1] <= B[0] || B[1] <= A[0]) {
			System.out.println(0);
			System.exit(0);
		}

		if(A[0] < B[0]) {
			min = B[0];
		}else {
			min = A[0];
		}

		if(A[1] < B[1]) {
			max = A[1];
		}else {
			max = B[1];
		}

		System.out.println(max - min);
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] A, B;
		int min,max;
		A = new int[2];
		B = new int[2];
		for(int i = 0; i < 2; i++) {
			A[i] = sc.nextInt();
		}
		for(int i = 0; i < 2; i++) {
			B[i] = sc.nextInt();
		}

		if(A[1] <= B[0] || B[1] <= A[0]) {
			System.out.println(0);
			System.exit(0);
		}

		if(A[0] < B[0]) {
			min = B[0];
		}else {
			min = A[0];
		}

		if(A[1] < B[1]) {
			max = A[1];
		}else {
			max = B[1];
		}

		System.out.println(max - min);
		sc.close();
	}
}
