import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.Scanner;
 //O(100000000)
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = Long.parseLong(sc.next());
        long D = Long.parseLong(sc.next());

        int[] g = new int[100];
        for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        }
        for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        }
        
         for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        }
        
        

        System.out.print(cnt);
        System.out.println();
    }
} import java.io.Closeable; Closeable java.io import java.io.File; File java.io import java.io.FileInputStream; FileInputStream java.io import java.io.FileNotFoundException; FileNotFoundException java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.util.NoSuchElementException; NoSuchElementException java.util import java.util.Scanner; Scanner java.util ublic class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = Long.parseLong(sc.next());
        long D = Long.parseLong(sc.next());

        int[] g = new int[100];
        for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        }
        for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        }
        
         for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        }
        
        

        System.out.print(cnt);
        System.out.println();
    }
} Main public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = Long.parseLong(sc.next());
        long D = Long.parseLong(sc.next());

        int[] g = new int[100];
        for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        }
        for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        }
        
         for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        }
        
        

        System.out.print(cnt);
        System.out.println();
    } main {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = Long.parseLong(sc.next());
        long D = Long.parseLong(sc.next());

        int[] g = new int[100];
        for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        }
        for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        }
        
         for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        }
        
        

        System.out.print(cnt);
        System.out.println();
    } Scanner sc  = new Scanner(System.in); sc new Scanner(System.in) int cnt = 0; cnt 0 long A = Long.parseLong(sc.next()); A Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc long B = Long.parseLong(sc.next()); B Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc long C = Long.parseLong(sc.next()); C Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc long D = Long.parseLong(sc.next()); D Long.parseLong(sc.next()) Long.parseLong Long sc.next() sc.next sc int[] g = new int[100]; g new int[100] 100 for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        } int i=(int)A; int i=(int)A; i (int)A i<(int)B i (int)B i++ i++ i {
           g[i]++;
        } {
           g[i]++;
        } g[i]++ g[i] g i for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        } int i=(int)C; int i=(int)C; i (int)C i<(int)D i (int)D i++ i++ i {
           g[i]++;
        } {
           g[i]++;
        } g[i]++ g[i] g i for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        } int i=0; int i=0; i 0 i<100 i 100 i++ i++ i {
           if(g[i]==2) cnt++;
        } {
           if(g[i]==2) cnt++;
        } if(g[i]==2) cnt++; g[i]==2 g[i] g i 2 cnt++ cnt System.out.print(cnt) System.out.print System.out System System.out cnt System.out.println() System.out.println System.out System System.out String[] args args ublic class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = Long.parseLong(sc.next());
        long D = Long.parseLong(sc.next());

        int[] g = new int[100];
        for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        }
        for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        }
        
         for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        }
        
        

        System.out.print(cnt);
        System.out.println();
    }
} ublic class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = Long.parseLong(sc.next());
        long D = Long.parseLong(sc.next());

        int[] g = new int[100];
        for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        }
        for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        }
        
         for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        }
        
        

        System.out.print(cnt);
        System.out.println();
    }
} Main
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.util.Scanner;
 //O(100000000)
public class Main {
    public static void main(String[] args) {

        Scanner sc  = new Scanner(System.in);

        int cnt = 0;

        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());
        long C = Long.parseLong(sc.next());
        long D = Long.parseLong(sc.next());

        int[] g = new int[100];
        for(int i=(int)A;i<(int)B;i++){
           g[i]++;
        }
        for(int i=(int)C;i<(int)D;i++){
           g[i]++;
        }
        
         for(int i=0;i<100;i++){
           if(g[i]==2) cnt++;
        }
        
        

        System.out.print(cnt);
        System.out.println();
    }
}