import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();

		int small = (a > c)? a : c;
		int large = (b < d)? b : d;

		int time = (large > small)? large-small : 0;
		System.out.println(time);
	}
} import java.util.Scanner; Scanner java.util class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();

		int small = (a > c)? a : c;
		int large = (b < d)? b : d;

		int time = (large > small)? large-small : 0;
		System.out.println(time);
	}
} Main public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();

		int small = (a > c)? a : c;
		int large = (b < d)? b : d;

		int time = (large > small)? large-small : 0;
		System.out.println(time);
	} main {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();

		int small = (a > c)? a : c;
		int large = (b < d)? b : d;

		int time = (large > small)? large-small : 0;
		System.out.println(time);
	} Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int a = stdIn.nextInt(); a stdIn.nextInt() stdIn.nextInt stdIn int b = stdIn.nextInt(); b stdIn.nextInt() stdIn.nextInt stdIn int c = stdIn.nextInt(); c stdIn.nextInt() stdIn.nextInt stdIn int d = stdIn.nextInt(); d stdIn.nextInt() stdIn.nextInt stdIn int small = (a > c)? a : c; small (a > c)? a : c (a > c) a c a c int large = (b < d)? b : d; large (b < d)? b : d (b < d) b d b d int time = (large > small)? large-small : 0; time (large > small)? large-small : 0 (large > small) large small large-small large small 0 System.out.println(time) System.out.println System.out System System.out time String[] args args
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		int d = stdIn.nextInt();

		int small = (a > c)? a : c;
		int large = (b < d)? b : d;

		int time = (large > small)? large-small : 0;
		System.out.println(time);
	}
}