import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a, b, c, d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		if (a < c) {
			a = c;
		}
		if (b > d) {
			b = d;
		}
		if (b - a < 0) {
			System.out.println(0);
		} else {
			System.out.println(b - a);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a, b, c, d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		if (a < c) {
			a = c;
		}
		if (b > d) {
			b = d;
		}
		if (b - a < 0) {
			System.out.println(0);
		} else {
			System.out.println(b - a);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a, b, c, d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		if (a < c) {
			a = c;
		}
		if (b > d) {
			b = d;
		}
		if (b - a < 0) {
			System.out.println(0);
		} else {
			System.out.println(b - a);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a, b, c, d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		if (a < c) {
			a = c;
		}
		if (b > d) {
			b = d;
		}
		if (b - a < 0) {
			System.out.println(0);
		} else {
			System.out.println(b - a);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int a a b b c c d; d 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 if (a < c) {
			a = c;
		} a < c a c {
			a = c;
		} a = c a c if (b > d) {
			b = d;
		} b > d b d {
			b = d;
		} b = d b d if (b - a < 0) {
			System.out.println(0);
		} else {
			System.out.println(b - a);
		} b - a < 0 b - a b a 0 {
			System.out.println(0);
		} System.out.println(0) System.out.println System.out System System.out 0 {
			System.out.println(b - a);
		} System.out.println(b - a) System.out.println System.out System System.out b - a b a String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a, b, c, d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		if (a < c) {
			a = c;
		}
		if (b > d) {
			b = d;
		}
		if (b - a < 0) {
			System.out.println(0);
		} else {
			System.out.println(b - a);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a, b, c, d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		if (a < c) {
			a = c;
		}
		if (b > d) {
			b = d;
		}
		if (b - a < 0) {
			System.out.println(0);
		} else {
			System.out.println(b - a);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int a, b, c, d;
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		if (a < c) {
			a = c;
		}
		if (b > d) {
			b = d;
		}
		if (b - a < 0) {
			System.out.println(0);
		} else {
			System.out.println(b - a);
		}
	}
}
