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 max = 0;
      	int min = 0;
      	if(A <= C){
          max = C;
        }else{
          max = A;
        }
      
      	if(B <= D){
          min = B;
        }else{
          min = D;
        }
		int result = 0;
      	if(max <= min){
          result = min - max;
        }
      
      	System.out.println(result);
    }
} 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 max = 0;
      	int min = 0;
      	if(A <= C){
          max = C;
        }else{
          max = A;
        }
      
      	if(B <= D){
          min = B;
        }else{
          min = D;
        }
		int result = 0;
      	if(max <= min){
          result = min - max;
        }
      
      	System.out.println(result);
    }
} 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 max = 0;
      	int min = 0;
      	if(A <= C){
          max = C;
        }else{
          max = A;
        }
      
      	if(B <= D){
          min = B;
        }else{
          min = D;
        }
		int result = 0;
      	if(max <= min){
          result = min - max;
        }
      
      	System.out.println(result);
    } main {
    	Scanner sc = new Scanner(System.in);
      	int A = sc.nextInt();
      	int B = sc.nextInt();
      	int C = sc.nextInt();
      	int D = sc.nextInt();
      	
      	int max = 0;
      	int min = 0;
      	if(A <= C){
          max = C;
        }else{
          max = A;
        }
      
      	if(B <= D){
          min = B;
        }else{
          min = D;
        }
		int result = 0;
      	if(max <= min){
          result = min - max;
        }
      
      	System.out.println(result);
    } 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 max = 0; max 0 int min = 0; min 0 if(A <= C){
          max = C;
        }else{
          max = A;
        } A <= C A C {
          max = C;
        } max = C max C {
          max = A;
        } max = A max A if(B <= D){
          min = B;
        }else{
          min = D;
        } B <= D B D {
          min = B;
        } min = B min B {
          min = D;
        } min = D min D int result = 0; result 0 if(max <= min){
          result = min - max;
        } max <= min max min {
          result = min - max;
        } result = min - max result min - max min max System.out.println(result) System.out.println System.out System System.out result 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 max = 0;
      	int min = 0;
      	if(A <= C){
          max = C;
        }else{
          max = A;
        }
      
      	if(B <= D){
          min = B;
        }else{
          min = D;
        }
		int result = 0;
      	if(max <= min){
          result = min - max;
        }
      
      	System.out.println(result);
    }
} 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 max = 0;
      	int min = 0;
      	if(A <= C){
          max = C;
        }else{
          max = A;
        }
      
      	if(B <= D){
          min = B;
        }else{
          min = D;
        }
		int result = 0;
      	if(max <= min){
          result = min - max;
        }
      
      	System.out.println(result);
    }
} 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 max = 0;
      	int min = 0;
      	if(A <= C){
          max = C;
        }else{
          max = A;
        }
      
      	if(B <= D){
          min = B;
        }else{
          min = D;
        }
		int result = 0;
      	if(max <= min){
          result = min - max;
        }
      
      	System.out.println(result);
    }
}