import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		int count = 0;
		int ans = 0;
		while(count < 101) {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		}
		System.out.println(ans);
	}
} 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(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		int count = 0;
		int ans = 0;
		while(count < 101) {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		}
		System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		int count = 0;
		int ans = 0;
		while(count < 101) {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		int count = 0;
		int ans = 0;
		while(count < 101) {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt() A sc.nextInt() sc.nextInt sc B = sc.nextInt() B sc.nextInt() sc.nextInt sc C = sc.nextInt() C sc.nextInt() sc.nextInt sc D = sc.nextInt(); D sc.nextInt() sc.nextInt sc int count = 0; count 0 int ans = 0; ans 0 while(count < 101) {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		} count < 101 count 101 {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		} if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			} count >= A && count >= C &&
				count < B && count < D count < B count >= A && count >= C &&
				count < B && count < D count >= A count A count >= C count C count < B count B count < D count D {
				ans++;
			} ans++ ans count++ count 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 sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		int count = 0;
		int ans = 0;
		while(count < 101) {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		}
		System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		int count = 0;
		int ans = 0;
		while(count < 101) {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		int count = 0;
		int ans = 0;
		while(count < 101) {
			if(count >= A && count >= C &&
				count < B && count < D) {
				ans++;
			}
			count++;
		}
		System.out.println(ans);
	}
}
