import java.util.*;
import java.io.*; 

public class Main {

	public static void main (String[] args) throws IOException
	{
	    
		BufferedReader br= new BufferedReader (new InputStreamReader(System.in) );
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int[] A= new int[2];
		int[] B  = new int[2];
		int max_low=0;
		int min_high=0;
		
		A[0] = Integer.parseInt(st.nextToken());
        A[1] = Integer.parseInt(st.nextToken());
        B[0] = Integer.parseInt(st.nextToken());
        B[1] = Integer.parseInt(st.nextToken());
		
		max_low=Math.max(A[0],B[0]);
		min_high= Math.min(A[1],B[1]);
		
		if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low);
		
		
	}
} import java.util.*; util.* java import java.io.*; io.* java public class Main {

	public static void main (String[] args) throws IOException
	{
	    
		BufferedReader br= new BufferedReader (new InputStreamReader(System.in) );
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int[] A= new int[2];
		int[] B  = new int[2];
		int max_low=0;
		int min_high=0;
		
		A[0] = Integer.parseInt(st.nextToken());
        A[1] = Integer.parseInt(st.nextToken());
        B[0] = Integer.parseInt(st.nextToken());
        B[1] = Integer.parseInt(st.nextToken());
		
		max_low=Math.max(A[0],B[0]);
		min_high= Math.min(A[1],B[1]);
		
		if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low);
		
		
	}
} Main public static void main (String[] args) throws IOException
	{
	    
		BufferedReader br= new BufferedReader (new InputStreamReader(System.in) );
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int[] A= new int[2];
		int[] B  = new int[2];
		int max_low=0;
		int min_high=0;
		
		A[0] = Integer.parseInt(st.nextToken());
        A[1] = Integer.parseInt(st.nextToken());
        B[0] = Integer.parseInt(st.nextToken());
        B[1] = Integer.parseInt(st.nextToken());
		
		max_low=Math.max(A[0],B[0]);
		min_high= Math.min(A[1],B[1]);
		
		if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low);
		
		
	} main {
	    
		BufferedReader br= new BufferedReader (new InputStreamReader(System.in) );
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int[] A= new int[2];
		int[] B  = new int[2];
		int max_low=0;
		int min_high=0;
		
		A[0] = Integer.parseInt(st.nextToken());
        A[1] = Integer.parseInt(st.nextToken());
        B[0] = Integer.parseInt(st.nextToken());
        B[1] = Integer.parseInt(st.nextToken());
		
		max_low=Math.max(A[0],B[0]);
		min_high= Math.min(A[1],B[1]);
		
		if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low);
		
		
	} BufferedReader br= new BufferedReader (new InputStreamReader(System.in) ); br new BufferedReader (new InputStreamReader(System.in) ) StringTokenizer st = new StringTokenizer(br.readLine()); st new StringTokenizer(br.readLine()) int[] A= new int[2]; A new int[2] 2 int[] B  = new int[2]; B new int[2] 2 int max_low=0; max_low 0 int min_high=0; min_high 0 A[0] = Integer.parseInt(st.nextToken()) A[0] A 0 Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st A[1] = Integer.parseInt(st.nextToken()) A[1] A 1 Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st B[0] = Integer.parseInt(st.nextToken()) B[0] B 0 Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st B[1] = Integer.parseInt(st.nextToken()) B[1] B 1 Integer.parseInt(st.nextToken()) Integer.parseInt Integer st.nextToken() st.nextToken st max_low=Math.max(A[0],B[0]) max_low Math.max(A[0],B[0]) Math.max Math A[0] A 0 B[0] B 0 min_high= Math.min(A[1],B[1]) min_high Math.min(A[1],B[1]) Math.min Math A[1] A 1 B[1] B 1 if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low); max_low>min_high max_low min_high System.out.println("0") System.out.println System.out System System.out "0" System.out.println(min_high-max_low) System.out.println System.out System System.out min_high-max_low min_high max_low String[] args args public class Main {

	public static void main (String[] args) throws IOException
	{
	    
		BufferedReader br= new BufferedReader (new InputStreamReader(System.in) );
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int[] A= new int[2];
		int[] B  = new int[2];
		int max_low=0;
		int min_high=0;
		
		A[0] = Integer.parseInt(st.nextToken());
        A[1] = Integer.parseInt(st.nextToken());
        B[0] = Integer.parseInt(st.nextToken());
        B[1] = Integer.parseInt(st.nextToken());
		
		max_low=Math.max(A[0],B[0]);
		min_high= Math.min(A[1],B[1]);
		
		if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low);
		
		
	}
} public class Main {

	public static void main (String[] args) throws IOException
	{
	    
		BufferedReader br= new BufferedReader (new InputStreamReader(System.in) );
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int[] A= new int[2];
		int[] B  = new int[2];
		int max_low=0;
		int min_high=0;
		
		A[0] = Integer.parseInt(st.nextToken());
        A[1] = Integer.parseInt(st.nextToken());
        B[0] = Integer.parseInt(st.nextToken());
        B[1] = Integer.parseInt(st.nextToken());
		
		max_low=Math.max(A[0],B[0]);
		min_high= Math.min(A[1],B[1]);
		
		if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low);
		
		
	}
} Main
import java.util.*;
import java.io.*; 

public class Main {

	public static void main (String[] args) throws IOException
	{
	    
		BufferedReader br= new BufferedReader (new InputStreamReader(System.in) );
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		int[] A= new int[2];
		int[] B  = new int[2];
		int max_low=0;
		int min_high=0;
		
		A[0] = Integer.parseInt(st.nextToken());
        A[1] = Integer.parseInt(st.nextToken());
        B[0] = Integer.parseInt(st.nextToken());
        B[1] = Integer.parseInt(st.nextToken());
		
		max_low=Math.max(A[0],B[0]);
		min_high= Math.min(A[1],B[1]);
		
		if (max_low>min_high)
			System.out.println("0");
		
		else
			System.out.println(min_high-max_low);
		
		
	}
}