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 count = 0;
        for(int i = 0; i < 100; i++){
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        }
        System.out.print(count);
    }
} 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 count = 0;
        for(int i = 0; i < 100; i++){
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        }
        System.out.print(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 count = 0;
        for(int i = 0; i < 100; i++){
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        }
        System.out.print(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 count = 0;
        for(int i = 0; i < 100; i++){
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        }
        System.out.print(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 count = 0; count 0 for(int i = 0; i < 100; i++){
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        } int i = 0; int i = 0; i 0 i < 100 i 100 i++ i++ i {
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        } {
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        } if(a <= i && i < b && c <= i && i < d){
                count++;
            } a <= i && i < b && c <= i && i < d c <= i a <= i && i < b && c <= i && i < d a <= i a i i < b i b c <= i c i i < d i d {
                count++;
            } count++ count System.out.print(count) System.out.print 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 count = 0;
        for(int i = 0; i < 100; i++){
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        }
        System.out.print(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 count = 0;
        for(int i = 0; i < 100; i++){
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        }
        System.out.print(count);
    }
} 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 count = 0;
        for(int i = 0; i < 100; i++){
            if(a <= i && i < b && c <= i && i < d){
                count++;
            }
        }
        System.out.print(count);
    }
}