import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	int S=a<=c?c:a;
	int F=b<=d?b:d;
	System.out.println(S<F?F-S:0);
}
} import java.util.Scanner; Scanner java.util public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	int S=a<=c?c:a;
	int F=b<=d?b:d;
	System.out.println(S<F?F-S:0);
}
} Main public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	int S=a<=c?c:a;
	int F=b<=d?b:d;
	System.out.println(S<F?F-S:0);
} main {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	int S=a<=c?c:a;
	int F=b<=d?b:d;
	System.out.println(S<F?F-S:0);
} Scanner scan=new Scanner(System.in); scan new Scanner(System.in) int a=scan.nextInt(); a scan.nextInt() scan.nextInt scan int b=scan.nextInt(); b scan.nextInt() scan.nextInt scan int c=scan.nextInt(); c scan.nextInt() scan.nextInt scan int d=scan.nextInt(); d scan.nextInt() scan.nextInt scan int S=a<=c?c:a; S a<=c?c:a a<=c a c c a int F=b<=d?b:d; F b<=d?b:d b<=d b d b d System.out.println(S<F?F-S:0) System.out.println System.out System System.out S<F?F-S:0 S<F S F F-S F S 0 String[]srgs srgs public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	int S=a<=c?c:a;
	int F=b<=d?b:d;
	System.out.println(S<F?F-S:0);
}
} public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	int S=a<=c?c:a;
	int F=b<=d?b:d;
	System.out.println(S<F?F-S:0);
}
} Main
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c=scan.nextInt();
	int d=scan.nextInt();
	int S=a<=c?c:a;
	int F=b<=d?b:d;
	System.out.println(S<F?F-S:0);
}
}