import 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 min = A < C ? C : A;
		int max = B < D ? B : D;

		int out = max < min ? 0 : max - min;
		System.out.println(out);
	}
} import java.util.*; util.* java 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 min = A < C ? C : A;
		int max = B < D ? B : D;

		int out = max < min ? 0 : max - min;
		System.out.println(out);
	}
} 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 min = A < C ? C : A;
		int max = B < D ? B : D;

		int out = max < min ? 0 : max - min;
		System.out.println(out);
	} main {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		int min = A < C ? C : A;
		int max = B < D ? B : D;

		int out = max < min ? 0 : max - min;
		System.out.println(out);
	} 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 min = A < C ? C : A; min A < C ? C : A A < C A C C A int max = B < D ? B : D; max B < D ? B : D B < D B D B D int out = max < min ? 0 : max - min; out max < min ? 0 : max - min max < min max min 0 max - min max min System.out.println(out) System.out.println System.out System System.out out 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 min = A < C ? C : A;
		int max = B < D ? B : D;

		int out = max < min ? 0 : max - min;
		System.out.println(out);
	}
} 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 min = A < C ? C : A;
		int max = B < D ? B : D;

		int out = max < min ? 0 : max - min;
		System.out.println(out);
	}
} Main
import 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 min = A < C ? C : A;
		int max = B < D ? B : D;

		int out = max < min ? 0 : max - min;
		System.out.println(out);
	}
}
