import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() , b = sc.nextInt(), 
				c = sc.nextInt(), d = sc.nextInt();
		
		if(Math.min(b, d)-Math.max(a, c)>0) {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		}
		else System.out.print("0");
	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() , b = sc.nextInt(), 
				c = sc.nextInt(), d = sc.nextInt();
		
		if(Math.min(b, d)-Math.max(a, c)>0) {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		}
		else System.out.print("0");
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() , b = sc.nextInt(), 
				c = sc.nextInt(), d = sc.nextInt();
		
		if(Math.min(b, d)-Math.max(a, c)>0) {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		}
		else System.out.print("0");
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() , b = sc.nextInt(), 
				c = sc.nextInt(), d = sc.nextInt();
		
		if(Math.min(b, d)-Math.max(a, c)>0) {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		}
		else System.out.print("0");
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc c = sc.nextInt() c sc.nextInt() sc.nextInt sc d = sc.nextInt(); d sc.nextInt() sc.nextInt sc if(Math.min(b, d)-Math.max(a, c)>0) {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		}
		else System.out.print("0"); Math.min(b, d)-Math.max(a, c)>0 Math.min(b, d)-Math.max(a, c) Math.min(b, d) Math.min Math b d Math.max(a, c) Math.max Math a c 0 {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		} System.out.print(Math.min(b, d)-Math.max(a, c)) System.out.print System.out System System.out Math.min(b, d)-Math.max(a, c) Math.min(b, d) Math.min Math b d Math.max(a, c) Math.max Math a c System.out.print("0") System.out.print System.out System System.out "0" String[] args args public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() , b = sc.nextInt(), 
				c = sc.nextInt(), d = sc.nextInt();
		
		if(Math.min(b, d)-Math.max(a, c)>0) {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		}
		else System.out.print("0");
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() , b = sc.nextInt(), 
				c = sc.nextInt(), d = sc.nextInt();
		
		if(Math.min(b, d)-Math.max(a, c)>0) {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		}
		else System.out.print("0");
	}

} Main
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() , b = sc.nextInt(), 
				c = sc.nextInt(), d = sc.nextInt();
		
		if(Math.min(b, d)-Math.max(a, c)>0) {
			System.out.print(Math.min(b, d)-Math.max(a, c));
		}
		else System.out.print("0");
	}

}