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();
		sc.close();
		if (B > D) {
			B = D;
		}
		if (A > C) {
			C = A;
		}
		if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		}
	}
} 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();
		sc.close();
		if (B > D) {
			B = D;
		}
		if (A > C) {
			C = A;
		}
		if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		}
	}
} 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();
		sc.close();
		if (B > D) {
			B = D;
		}
		if (A > C) {
			C = A;
		}
		if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
		sc.close();
		if (B > D) {
			B = D;
		}
		if (A > C) {
			C = A;
		}
		if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		}
	} 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 sc.close() sc.close sc if (B > D) {
			B = D;
		} B > D B D {
			B = D;
		} B = D B D if (A > C) {
			C = A;
		} A > C A C {
			C = A;
		} C = A C A if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		} B - C > 0 B - C B C 0 {
			System.out.println(B - C);
		} System.out.println(B - C) System.out.println System.out System System.out B - C B C {
			System.out.println(0);
		} System.out.println(0) System.out.println System.out System System.out 0 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();
		sc.close();
		if (B > D) {
			B = D;
		}
		if (A > C) {
			C = A;
		}
		if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		}
	}
} 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();
		sc.close();
		if (B > D) {
			B = D;
		}
		if (A > C) {
			C = A;
		}
		if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		}
	}
} 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();
		sc.close();
		if (B > D) {
			B = D;
		}
		if (A > C) {
			C = A;
		}
		if (B - C > 0) {
			System.out.println(B - C);
		} else {
			System.out.println(0);
		}
	}
}
