import java.util.*;

public class Main{
	public static void main(String[] args){
	    Scanner scanner = new Scanner(System.in);
	    int[] array = new int[4];
	    int ans=-1;
	    for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    }
	    if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    }
	    if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    }
	    if(ans<0)ans = 0;
		System.out.println(ans);
	}
} import java.util.*; util.* java public class Main{
	public static void main(String[] args){
	    Scanner scanner = new Scanner(System.in);
	    int[] array = new int[4];
	    int ans=-1;
	    for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    }
	    if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    }
	    if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    }
	    if(ans<0)ans = 0;
		System.out.println(ans);
	}
} Main public static void main(String[] args){
	    Scanner scanner = new Scanner(System.in);
	    int[] array = new int[4];
	    int ans=-1;
	    for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    }
	    if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    }
	    if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    }
	    if(ans<0)ans = 0;
		System.out.println(ans);
	} main {
	    Scanner scanner = new Scanner(System.in);
	    int[] array = new int[4];
	    int ans=-1;
	    for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    }
	    if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    }
	    if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    }
	    if(ans<0)ans = 0;
		System.out.println(ans);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int[] array = new int[4]; array new int[4] 4 int ans=-1; ans -1 1 for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    } int i=0; int i=0; i 0 i<4 i 4 i++ i++ i {   
		array[i]=scanner.nextInt();
	    } {   
		array[i]=scanner.nextInt();
	    } array[i]=scanner.nextInt() array[i] array i scanner.nextInt() scanner.nextInt scanner if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    } array[0]<=array[2] array[0] array 0 array[2] array 2 {
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    } if(array[1]<=array[3])ans=array[1]-array[2]; array[1]<=array[3] array[1] array 1 array[3] array 3 ans=array[1]-array[2] ans array[1]-array[2] array[1] array 1 array[2] array 2 if(array[3]<=array[1])ans=array[3]-array[2]; array[3]<=array[1] array[3] array 3 array[1] array 1 ans=array[3]-array[2] ans array[3]-array[2] array[3] array 3 array[2] array 2 if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    } array[2]<array[0] array[2] array 2 array[0] array 0 {
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    } if(array[1]<=array[3])ans=array[1]-array[0]; array[1]<=array[3] array[1] array 1 array[3] array 3 ans=array[1]-array[0] ans array[1]-array[0] array[1] array 1 array[0] array 0 if(array[3]<=array[1])ans=array[3]-array[0]; array[3]<=array[1] array[3] array 3 array[1] array 1 ans=array[3]-array[0] ans array[3]-array[0] array[3] array 3 array[0] array 0 if(ans<0)ans = 0; ans<0 ans 0 ans = 0 ans 0 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
	public static void main(String[] args){
	    Scanner scanner = new Scanner(System.in);
	    int[] array = new int[4];
	    int ans=-1;
	    for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    }
	    if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    }
	    if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    }
	    if(ans<0)ans = 0;
		System.out.println(ans);
	}
} public class Main{
	public static void main(String[] args){
	    Scanner scanner = new Scanner(System.in);
	    int[] array = new int[4];
	    int ans=-1;
	    for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    }
	    if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    }
	    if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    }
	    if(ans<0)ans = 0;
		System.out.println(ans);
	}
} Main
import java.util.*;

public class Main{
	public static void main(String[] args){
	    Scanner scanner = new Scanner(System.in);
	    int[] array = new int[4];
	    int ans=-1;
	    for(int i=0;i<4;i++){   
		array[i]=scanner.nextInt();
	    }
	    if(array[0]<=array[2]){
		if(array[1]<=array[3])ans=array[1]-array[2];
		if(array[3]<=array[1])ans=array[3]-array[2];
	    }
	    if(array[2]<array[0]){
		if(array[1]<=array[3])ans=array[1]-array[0];
		if(array[3]<=array[1])ans=array[3]-array[0];
	    }
	    if(ans<0)ans = 0;
		System.out.println(ans);
	}
}