import java.util.Scanner;

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