import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int sec = 0;
		if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		}
		if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		}
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int sec = 0;
		if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		}
		if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int sec = 0;
		if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		}
		if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int sec = 0;
		if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		}
		if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int C = sc.nextInt(); C sc.nextInt() sc.nextInt sc int D = sc.nextInt(); D sc.nextInt() sc.nextInt sc int sec = 0; sec 0 if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		} A > C A C {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		} int x = A; x A A = C A C C = x C x x = B x B B = D B D D = x D x if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		} B < C B C System.out.println(sec) System.out.println System.out System System.out sec if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		} B < D B D {
			sec = B - C;
			System.out.println(sec);
		} sec = B - C sec B - C B C System.out.println(sec) System.out.println System.out System System.out sec {
			sec = D - C;
			System.out.println(sec);
		} sec = D - C sec D - C D C System.out.println(sec) System.out.println System.out System System.out sec String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int sec = 0;
		if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		}
		if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int sec = 0;
		if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		}
		if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		}
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int sec = 0;
		if(A > C) {
			int x = A;
			A = C;
			C = x;
			x = B;
			B = D;
			D = x;
		}
		if(B < C) System.out.println(sec);
		else if(B < D){
			sec = B - C;
			System.out.println(sec);
		}else{
			sec = D - C;
			System.out.println(sec);
		}
	}
}