import java.util.Scanner;

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 time = 0;
		for (int i = 0; i <= 100; i++) {
			if (a <= i && c <= i && i < b && i < d) time++;
		}
		
		System.out.println(time);
		
		sc.close();
	}
}

 import java.util.Scanner; Scanner 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 time = 0;
		for (int i = 0; i <= 100; i++) {
			if (a <= i && c <= i && i < b && i < d) time++;
		}
		
		System.out.println(time);
		
		sc.close();
	}
} 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 time = 0;
		for (int i = 0; i <= 100; i++) {
			if (a <= i && c <= i && i < b && i < d) time++;
		}
		
		System.out.println(time);
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		int time = 0;
		for (int i = 0; i <= 100; i++) {
			if (a <= i && c <= i && i < b && i < d) time++;
		}
		
		System.out.println(time);
		
		sc.close();
	} 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 time = 0; time 0 for (int i = 0; i <= 100; i++) {
			if (a <= i && c <= i && i < b && i < d) time++;
		} int i = 0; int i = 0; i 0 i <= 100 i 100 i++ i++ i {
			if (a <= i && c <= i && i < b && i < d) time++;
		} {
			if (a <= i && c <= i && i < b && i < d) time++;
		} if (a <= i && c <= i && i < b && i < d) time++; a <= i && c <= i && i < b && i < d i < b a <= i && c <= i && i < b && i < d a <= i a i c <= i c i i < b i b i < d i d time++ time System.out.println(time) System.out.println System.out System System.out time sc.close() sc.close sc 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 time = 0;
		for (int i = 0; i <= 100; i++) {
			if (a <= i && c <= i && i < b && i < d) time++;
		}
		
		System.out.println(time);
		
		sc.close();
	}
} 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 time = 0;
		for (int i = 0; i <= 100; i++) {
			if (a <= i && c <= i && i < b && i < d) time++;
		}
		
		System.out.println(time);
		
		sc.close();
	}
} Main
import java.util.Scanner;

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 time = 0;
		for (int i = 0; i <= 100; i++) {
			if (a <= i && c <= i && i < b && i < d) time++;
		}
		
		System.out.println(time);
		
		sc.close();
	}
}


