import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int start = (A > C) ? A : C;
		int end = (B < D) ? B : D;
		
		System.out.println((end - start >= 0) ? end - start : 0);
	}
} import java.io.File; File java.io import java.io.IOException; IOException java.io import java.util.*; util.* java public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int start = (A > C) ? A : C;
		int end = (B < D) ? B : D;
		
		System.out.println((end - start >= 0) ? end - start : 0);
	}
} Main public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int start = (A > C) ? A : C;
		int end = (B < D) ? B : D;
		
		System.out.println((end - start >= 0) ? end - start : 0);
	} main {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int start = (A > C) ? A : C;
		int end = (B < D) ? B : D;
		
		System.out.println((end - start >= 0) ? end - start : 0);
	} 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 start = (A > C) ? A : C; start (A > C) ? A : C (A > C) A C A C int end = (B < D) ? B : D; end (B < D) ? B : D (B < D) B D B D System.out.println((end - start >= 0) ? end - start : 0) System.out.println System.out System System.out (end - start >= 0) ? end - start : 0 (end - start >= 0) end - start end start 0 end - start end start 0 String[] args args public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int start = (A > C) ? A : C;
		int end = (B < D) ? B : D;
		
		System.out.println((end - start >= 0) ? end - start : 0);
	}
} public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int start = (A > C) ? A : C;
		int end = (B < D) ? B : D;
		
		System.out.println((end - start >= 0) ? end - start : 0);
	}
} Main
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int start = (A > C) ? A : C;
		int end = (B < D) ? B : D;
		
		System.out.println((end - start >= 0) ? end - start : 0);
	}
}