import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	int aliceOn = sc.nextInt();
	int aliceOff = sc.nextInt();
	int bobOn = sc.nextInt();
	int bobOff = sc.nextInt();

	int ans;

	if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	}

	System.out.println(ans);

	sc.close();

	}

} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	int aliceOn = sc.nextInt();
	int aliceOff = sc.nextInt();
	int bobOn = sc.nextInt();
	int bobOff = sc.nextInt();

	int ans;

	if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	}

	System.out.println(ans);

	sc.close();

	}

} Main public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	int aliceOn = sc.nextInt();
	int aliceOff = sc.nextInt();
	int bobOn = sc.nextInt();
	int bobOff = sc.nextInt();

	int ans;

	if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	}

	System.out.println(ans);

	sc.close();

	} main {

	Scanner sc = new Scanner(System.in);

	int aliceOn = sc.nextInt();
	int aliceOff = sc.nextInt();
	int bobOn = sc.nextInt();
	int bobOff = sc.nextInt();

	int ans;

	if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	}

	System.out.println(ans);

	sc.close();

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int aliceOn = sc.nextInt(); aliceOn sc.nextInt() sc.nextInt sc int aliceOff = sc.nextInt(); aliceOff sc.nextInt() sc.nextInt sc int bobOn = sc.nextInt(); bobOn sc.nextInt() sc.nextInt sc int bobOff = sc.nextInt(); bobOff sc.nextInt() sc.nextInt sc int ans; ans if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	} aliceOff < bobOn aliceOff bobOn {
		ans = 0;
	} ans = 0 ans 0 if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	} bobOff < aliceOn bobOff aliceOn {
		ans = 0;
	} ans = 0 ans 0 if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	} aliceOn <= bobOn && aliceOff >= bobOff aliceOn <= bobOn aliceOn bobOn aliceOff >= bobOff aliceOff bobOff {
		ans = bobOff - bobOn;
	} ans = bobOff - bobOn ans bobOff - bobOn bobOff bobOn if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	} aliceOn >= bobOn && aliceOff <= bobOff aliceOn >= bobOn aliceOn bobOn aliceOff <= bobOff aliceOff bobOff {
		ans = aliceOff - aliceOn;
	} ans = aliceOff - aliceOn ans aliceOff - aliceOn aliceOff aliceOn if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	} aliceOn > bobOn aliceOn bobOn {
		ans = bobOff - aliceOn;
	} ans = bobOff - aliceOn ans bobOff - aliceOn bobOff aliceOn {
		ans = aliceOff - bobOn;
	} ans = aliceOff - bobOn ans aliceOff - bobOn aliceOff bobOn System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	int aliceOn = sc.nextInt();
	int aliceOff = sc.nextInt();
	int bobOn = sc.nextInt();
	int bobOff = sc.nextInt();

	int ans;

	if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	}

	System.out.println(ans);

	sc.close();

	}

} public class Main {

	public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	int aliceOn = sc.nextInt();
	int aliceOff = sc.nextInt();
	int bobOn = sc.nextInt();
	int bobOff = sc.nextInt();

	int ans;

	if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	}

	System.out.println(ans);

	sc.close();

	}

} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sc = new Scanner(System.in);

	int aliceOn = sc.nextInt();
	int aliceOff = sc.nextInt();
	int bobOn = sc.nextInt();
	int bobOff = sc.nextInt();

	int ans;

	if(aliceOff < bobOn){
		ans = 0;
	} else if(bobOff < aliceOn) {
		ans = 0;
	} else if(aliceOn <= bobOn && aliceOff >= bobOff) {
		ans = bobOff - bobOn;
	} else if(aliceOn >= bobOn && aliceOff <= bobOff) {
		ans = aliceOff - aliceOn;
	} else if(aliceOn > bobOn) {
		ans = bobOff - aliceOn;
	} else {
		ans = aliceOff - bobOn;
	}

	System.out.println(ans);

	sc.close();

	}

}