import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int arr[] = new int[103];
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		arr[a+1]++; arr[b+1]--; arr[c+1]++; arr[d+1]--;
		
		
		int count = 0;
		for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		}
		
		System.out.println(count);
	}

} import java.util.*; util.* java public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int arr[] = new int[103];
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		arr[a+1]++; arr[b+1]--; arr[c+1]++; arr[d+1]--;
		
		
		int count = 0;
		for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		}
		
		System.out.println(count);
	}

} Main public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int arr[] = new int[103];
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		arr[a+1]++; arr[b+1]--; arr[c+1]++; arr[d+1]--;
		
		
		int count = 0;
		for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		}
		
		System.out.println(count);
	} main {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int arr[] = new int[103];
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		arr[a+1]++; arr[b+1]--; arr[c+1]++; arr[d+1]--;
		
		
		int count = 0;
		for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		}
		
		System.out.println(count);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int arr[] = new int[103]; arr new int[103] 103 int a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc c = sc.nextInt() c sc.nextInt() sc.nextInt sc d = sc.nextInt(); d sc.nextInt() sc.nextInt sc arr[a+1]++ arr[a+1] arr a+1 a 1 arr[b+1]-- arr[b+1] arr b+1 b 1 arr[c+1]++ arr[c+1] arr c+1 c 1 arr[d+1]-- arr[d+1] arr d+1 d 1 int count = 0; count 0 for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		} int i = 1; int i = 1; i 1 i<=100 i 100 i++ i++ i {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		} {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		} arr[i] += arr[i-1] arr[i] arr i arr[i-1] arr i-1 i 1 if(arr[i] == 2) count++; arr[i] == 2 arr[i] arr i 2 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) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int arr[] = new int[103];
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		arr[a+1]++; arr[b+1]--; arr[c+1]++; arr[d+1]--;
		
		
		int count = 0;
		for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		}
		
		System.out.println(count);
	}

} public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int arr[] = new int[103];
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		arr[a+1]++; arr[b+1]--; arr[c+1]++; arr[d+1]--;
		
		
		int count = 0;
		for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		}
		
		System.out.println(count);
	}

} Main
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int arr[] = new int[103];
		
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt();
		arr[a+1]++; arr[b+1]--; arr[c+1]++; arr[d+1]--;
		
		
		int count = 0;
		for(int i = 1; i<=100; i++) {
			arr[i] += arr[i-1];
			if(arr[i] == 2) count++;
		}
		
		System.out.println(count);
	}

}
