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 first = 0;
	int last = 0;

	if (A > C) {
		first = A;
	}else {
		first = C;
	}

	if (B > D) {
		last = D;
	}else {
		last = B;
	}
	if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	}
	}
} 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 first = 0;
	int last = 0;

	if (A > C) {
		first = A;
	}else {
		first = C;
	}

	if (B > D) {
		last = D;
	}else {
		last = B;
	}
	if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	}
	}
} 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 first = 0;
	int last = 0;

	if (A > C) {
		first = A;
	}else {
		first = C;
	}

	if (B > D) {
		last = D;
	}else {
		last = B;
	}
	if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	}
	} main {
	Scanner scan = new Scanner(System.in);
	int A = scan.nextInt();
	int B = scan.nextInt();
	int C = scan.nextInt();
	int D = scan.nextInt();

	int first = 0;
	int last = 0;

	if (A > C) {
		first = A;
	}else {
		first = C;
	}

	if (B > D) {
		last = D;
	}else {
		last = B;
	}
	if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	}
	} 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 first = 0; first 0 int last = 0; last 0 if (A > C) {
		first = A;
	}else {
		first = C;
	} A > C A C {
		first = A;
	} first = A first A {
		first = C;
	} first = C first C if (B > D) {
		last = D;
	}else {
		last = B;
	} B > D B D {
		last = D;
	} last = D last D {
		last = B;
	} last = B last B if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	} last > first last first {
		System.out.println(last - first);
	} System.out.println(last - first) System.out.println System.out System System.out last - first last first {
		System.out.println(0);
	} System.out.println(0) System.out.println System.out System System.out 0 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 first = 0;
	int last = 0;

	if (A > C) {
		first = A;
	}else {
		first = C;
	}

	if (B > D) {
		last = D;
	}else {
		last = B;
	}
	if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	}
	}
} 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 first = 0;
	int last = 0;

	if (A > C) {
		first = A;
	}else {
		first = C;
	}

	if (B > D) {
		last = D;
	}else {
		last = B;
	}
	if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	}
	}
} 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 first = 0;
	int last = 0;

	if (A > C) {
		first = A;
	}else {
		first = C;
	}

	if (B > D) {
		last = D;
	}else {
		last = B;
	}
	if (last > first) {
		System.out.println(last - first);
	}else {
		System.out.println(0);
	}
	}
}