import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int sta =0;
		int end =100;
		sta=Math.max(a, c);
		end = Math.min(b, d);
		int show = end-sta;
		if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	}
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int sta =0;
		int end =100;
		sta=Math.max(a, c);
		end = Math.min(b, d);
		int show = end-sta;
		if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	}
	}
} Main public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int sta =0;
		int end =100;
		sta=Math.max(a, c);
		end = Math.min(b, d);
		int show = end-sta;
		if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	}
	} main {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int sta =0;
		int end =100;
		sta=Math.max(a, c);
		end = Math.min(b, d);
		int show = end-sta;
		if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int c = scan.nextInt(); c scan.nextInt() scan.nextInt scan int d = scan.nextInt(); d scan.nextInt() scan.nextInt scan int sta =0; sta 0 int end =100; end 100 sta=Math.max(a, c) sta Math.max(a, c) Math.max Math a c end = Math.min(b, d) end Math.min(b, d) Math.min Math b d int show = end-sta; show end-sta end sta if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	} show<=0 show 0 {
			System.out.println(0);
		} System.out.println(0) System.out.println System.out System System.out 0 {
		System.out.println(end-sta);
	} System.out.println(end-sta) System.out.println System.out System System.out end-sta end sta String[] args args public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int sta =0;
		int end =100;
		sta=Math.max(a, c);
		end = Math.min(b, d);
		int show = end-sta;
		if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	}
	}
} public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int sta =0;
		int end =100;
		sta=Math.max(a, c);
		end = Math.min(b, d);
		int show = end-sta;
		if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	}
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		int sta =0;
		int end =100;
		sta=Math.max(a, c);
		end = Math.min(b, d);
		int show = end-sta;
		if(show<=0) {
			System.out.println(0);
		}else {
		System.out.println(end-sta);
	}
	}
}
