import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int a[] = new int[200];
		for (int i=A;i<B;i++) {
			a[i]++;
		}
		for (int i=C;i<D;i++) {
			a[i]++;
		}
		int count =0;
		for (int i=0;i<200;i++) {
			if (a[i]==2) {
				count ++;
			}
		}
		System.out.println(count);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int a[] = new int[200];
		for (int i=A;i<B;i++) {
			a[i]++;
		}
		for (int i=C;i<D;i++) {
			a[i]++;
		}
		int count =0;
		for (int i=0;i<200;i++) {
			if (a[i]==2) {
				count ++;
			}
		}
		System.out.println(count);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int a[] = new int[200];
		for (int i=A;i<B;i++) {
			a[i]++;
		}
		for (int i=C;i<D;i++) {
			a[i]++;
		}
		int count =0;
		for (int i=0;i<200;i++) {
			if (a[i]==2) {
				count ++;
			}
		}
		System.out.println(count);
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int a[] = new int[200];
		for (int i=A;i<B;i++) {
			a[i]++;
		}
		for (int i=C;i<D;i++) {
			a[i]++;
		}
		int count =0;
		for (int i=0;i<200;i++) {
			if (a[i]==2) {
				count ++;
			}
		}
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int C = sc.nextInt(); C sc.nextInt() sc.nextInt sc int D = sc.nextInt(); D sc.nextInt() sc.nextInt sc int a[] = new int[200]; a new int[200] 200 for (int i=A;i<B;i++) {
			a[i]++;
		} int i=A; int i=A; i A i<B i B i++ i++ i {
			a[i]++;
		} {
			a[i]++;
		} a[i]++ a[i] a i for (int i=C;i<D;i++) {
			a[i]++;
		} int i=C; int i=C; i C i<D i D i++ i++ i {
			a[i]++;
		} {
			a[i]++;
		} a[i]++ a[i] a i int count =0; count 0 for (int i=0;i<200;i++) {
			if (a[i]==2) {
				count ++;
			}
		} int i=0; int i=0; i 0 i<200 i 200 i++ i++ i {
			if (a[i]==2) {
				count ++;
			}
		} {
			if (a[i]==2) {
				count ++;
			}
		} if (a[i]==2) {
				count ++;
			} a[i]==2 a[i] a i 2 {
				count ++;
			} count ++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int a[] = new int[200];
		for (int i=A;i<B;i++) {
			a[i]++;
		}
		for (int i=C;i<D;i++) {
			a[i]++;
		}
		int count =0;
		for (int i=0;i<200;i++) {
			if (a[i]==2) {
				count ++;
			}
		}
		System.out.println(count);
	}
} public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int a[] = new int[200];
		for (int i=A;i<B;i++) {
			a[i]++;
		}
		for (int i=C;i<D;i++) {
			a[i]++;
		}
		int count =0;
		for (int i=0;i<200;i++) {
			if (a[i]==2) {
				count ++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int a[] = new int[200];
		for (int i=A;i<B;i++) {
			a[i]++;
		}
		for (int i=C;i<D;i++) {
			a[i]++;
		}
		int count =0;
		for (int i=0;i<200;i++) {
			if (a[i]==2) {
				count ++;
			}
		}
		System.out.println(count);
	}
}