import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		}
	}
  
} import java.util.Scanner; Scanner java.util public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		}
	}
  
} Main public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		}
	} main {
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		}
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		} input.hasNext() input.hasNext input {
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		} int A = input.nextInt(); A input.nextInt() input.nextInt input int B = input.nextInt(); B input.nextInt() input.nextInt input int C = input.nextInt(); C input.nextInt() input.nextInt input int D = input.nextInt(); D input.nextInt() input.nextInt input if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			} A > D || C > B A > D A D C > B C B {
				System.out.println("0");
			} System.out.println("0") System.out.println System.out System System.out "0" {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			} System.out.println(Math.min(B, D) - Math.max(A, C)) System.out.println 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 String[] args args public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		}
	}
  
} public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		}
	}
  
} Main
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		while(input.hasNext()){
			int A = input.nextInt();
			int B = input.nextInt();
			int C = input.nextInt();
			int D = input.nextInt();
			if(A > D || C > B){
				System.out.println("0");
			} else {
				System.out.println(Math.min(B, D) - Math.max(A, C));
			}
		}
	}
  
}