import java.util.*;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int one = sc.nextInt();
		int two = sc.nextInt();//B
		int three = sc.nextInt();
		int four = sc.nextInt();

		int min = Math.max(one, three);
		int max = Math.min(two, four);

		if (min < max) {
			System.out.println(max - min);
		} else {
			System.out.println(0);
		}
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int one = sc.nextInt();
		int two = sc.nextInt();//B
		int three = sc.nextInt();
		int four = sc.nextInt();

		int min = Math.max(one, three);
		int max = Math.min(two, four);

		if (min < max) {
			System.out.println(max - min);
		} else {
			System.out.println(0);
		}
	}
} Main public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int one = sc.nextInt();
		int two = sc.nextInt();//B
		int three = sc.nextInt();
		int four = sc.nextInt();

		int min = Math.max(one, three);
		int max = Math.min(two, four);

		if (min < max) {
			System.out.println(max - min);
		} else {
			System.out.println(0);
		}
	} main {

		Scanner sc = new Scanner(System.in);

		int one = sc.nextInt();
		int two = sc.nextInt();//B
		int three = sc.nextInt();
		int four = sc.nextInt();

		int min = Math.max(one, three);
		int max = Math.min(two, four);

		if (min < max) {
			System.out.println(max - min);
		} else {
			System.out.println(0);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int one = sc.nextInt(); one sc.nextInt() sc.nextInt sc int two = sc.nextInt(); two sc.nextInt() sc.nextInt sc int three = sc.nextInt(); three sc.nextInt() sc.nextInt sc int four = sc.nextInt(); four sc.nextInt() sc.nextInt sc int min = Math.max(one, three); min Math.max(one, three) Math.max Math one three int max = Math.min(two, four); max Math.min(two, four) Math.min Math two four if (min < max) {
			System.out.println(max - min);
		} else {
			System.out.println(0);
		} min < max min max {
			System.out.println(max - min);
		} System.out.println(max - min) System.out.println System.out System System.out max - min max min {
			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 one = sc.nextInt();
		int two = sc.nextInt();//B
		int three = sc.nextInt();
		int four = sc.nextInt();

		int min = Math.max(one, three);
		int max = Math.min(two, four);

		if (min < max) {
			System.out.println(max - min);
		} else {
			System.out.println(0);
		}
	}
} public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int one = sc.nextInt();
		int two = sc.nextInt();//B
		int three = sc.nextInt();
		int four = sc.nextInt();

		int min = Math.max(one, three);
		int max = Math.min(two, four);

		if (min < max) {
			System.out.println(max - min);
		} else {
			System.out.println(0);
		}
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int one = sc.nextInt();
		int two = sc.nextInt();//B
		int three = sc.nextInt();
		int four = sc.nextInt();

		int min = Math.max(one, three);
		int max = Math.min(two, four);

		if (min < max) {
			System.out.println(max - min);
		} else {
			System.out.println(0);
		}
	}
}
