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