import 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[] r = new int[101];
        
        for(int i = a; i <= b; i++){
            r[i]++;
        }
        
        for(int i = c; i <= d; i++){
            r[i]++;
        }
        
        int res = 0;
        
        for(int i = 0; i <= 100; i++){
            if(r[i] == 2) res++;
        }
        
        System.out.println(res == 0 ? 0 : res - 1);
    }
} import java.util.*; util.* java 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[] r = new int[101];
        
        for(int i = a; i <= b; i++){
            r[i]++;
        }
        
        for(int i = c; i <= d; i++){
            r[i]++;
        }
        
        int res = 0;
        
        for(int i = 0; i <= 100; i++){
            if(r[i] == 2) res++;
        }
        
        System.out.println(res == 0 ? 0 : res - 1);
    }
} 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[] r = new int[101];
        
        for(int i = a; i <= b; i++){
            r[i]++;
        }
        
        for(int i = c; i <= d; i++){
            r[i]++;
        }
        
        int res = 0;
        
        for(int i = 0; i <= 100; i++){
            if(r[i] == 2) res++;
        }
        
        System.out.println(res == 0 ? 0 : res - 1);
    } main {
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        
        int[] r = new int[101];
        
        for(int i = a; i <= b; i++){
            r[i]++;
        }
        
        for(int i = c; i <= d; i++){
            r[i]++;
        }
        
        int res = 0;
        
        for(int i = 0; i <= 100; i++){
            if(r[i] == 2) res++;
        }
        
        System.out.println(res == 0 ? 0 : res - 1);
    } 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[] r = new int[101]; r new int[101] 101 for(int i = a; i <= b; i++){
            r[i]++;
        } int i = a; int i = a; i a i <= b i b i++ i++ i {
            r[i]++;
        } {
            r[i]++;
        } r[i]++ r[i] r i for(int i = c; i <= d; i++){
            r[i]++;
        } int i = c; int i = c; i c i <= d i d i++ i++ i {
            r[i]++;
        } {
            r[i]++;
        } r[i]++ r[i] r i int res = 0; res 0 for(int i = 0; i <= 100; i++){
            if(r[i] == 2) res++;
        } int i = 0; int i = 0; i 0 i <= 100 i 100 i++ i++ i {
            if(r[i] == 2) res++;
        } {
            if(r[i] == 2) res++;
        } if(r[i] == 2) res++; r[i] == 2 r[i] r i 2 res++ res System.out.println(res == 0 ? 0 : res - 1) System.out.println System.out System System.out res == 0 ? 0 : res - 1 res == 0 res 0 0 res - 1 res 1 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[] r = new int[101];
        
        for(int i = a; i <= b; i++){
            r[i]++;
        }
        
        for(int i = c; i <= d; i++){
            r[i]++;
        }
        
        int res = 0;
        
        for(int i = 0; i <= 100; i++){
            if(r[i] == 2) res++;
        }
        
        System.out.println(res == 0 ? 0 : res - 1);
    }
} 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[] r = new int[101];
        
        for(int i = a; i <= b; i++){
            r[i]++;
        }
        
        for(int i = c; i <= d; i++){
            r[i]++;
        }
        
        int res = 0;
        
        for(int i = 0; i <= 100; i++){
            if(r[i] == 2) res++;
        }
        
        System.out.println(res == 0 ? 0 : res - 1);
    }
} Main
import 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[] r = new int[101];
        
        for(int i = a; i <= b; i++){
            r[i]++;
        }
        
        for(int i = c; i <= d; i++){
            r[i]++;
        }
        
        int res = 0;
        
        for(int i = 0; i <= 100; i++){
            if(r[i] == 2) res++;
        }
        
        System.out.println(res == 0 ? 0 : res - 1);
    }
}
