import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = 0;
		
		boolean[] exits = new boolean[100];
		Arrays.fill(exits, false);
		for (int i = a; i < b; i++){
			exits[i] = true;
		}
		for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		scanner.close();
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = 0;
		
		boolean[] exits = new boolean[100];
		Arrays.fill(exits, false);
		for (int i = a; i < b; i++){
			exits[i] = true;
		}
		for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		scanner.close();
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = 0;
		
		boolean[] exits = new boolean[100];
		Arrays.fill(exits, false);
		for (int i = a; i < b; i++){
			exits[i] = true;
		}
		for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		scanner.close();
	} main {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = 0;
		
		boolean[] exits = new boolean[100];
		Arrays.fill(exits, false);
		for (int i = a; i < b; i++){
			exits[i] = true;
		}
		for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		scanner.close();
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int a = scanner.nextInt(); a scanner.nextInt() scanner.nextInt scanner int b = scanner.nextInt(); b scanner.nextInt() scanner.nextInt scanner int c = scanner.nextInt(); c scanner.nextInt() scanner.nextInt scanner int d = scanner.nextInt(); d scanner.nextInt() scanner.nextInt scanner int ans = 0; ans 0 boolean[] exits = new boolean[100]; exits new boolean[100] 100 Arrays.fill(exits, false) Arrays.fill Arrays exits false for (int i = a; i < b; i++){
			exits[i] = true;
		} int i = a; int i = a; i a i < b i b i++ i++ i {
			exits[i] = true;
		} {
			exits[i] = true;
		} exits[i] = true exits[i] exits i true for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		} int i = c; int i = c; i c i < d i d i++ i++ i {
			if (exits[i]) {
				ans++;
			}
		} {
			if (exits[i]) {
				ans++;
			}
		} if (exits[i]) {
				ans++;
			} exits[i] exits i {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans scanner.close() scanner.close scanner String[] args args public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = 0;
		
		boolean[] exits = new boolean[100];
		Arrays.fill(exits, false);
		for (int i = a; i < b; i++){
			exits[i] = true;
		}
		for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		scanner.close();
	}
} public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = 0;
		
		boolean[] exits = new boolean[100];
		Arrays.fill(exits, false);
		for (int i = a; i < b; i++){
			exits[i] = true;
		}
		for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		scanner.close();
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int d = scanner.nextInt();
		int ans = 0;
		
		boolean[] exits = new boolean[100];
		Arrays.fill(exits, false);
		for (int i = a; i < b; i++){
			exits[i] = true;
		}
		for (int i = c; i < d; i++) {
			if (exits[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
		scanner.close();
	}
}