import java.util.*;

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();
        boolean[] Alice = new boolean[210];
        boolean[] Bob = new boolean[210];
        for(int i=A;i<B;i++) Alice[i] = true;
        for(int i=C;i<D;i++) Bob[i] = true;
        int ans = 0;
        for(int i=0;i<210;i++){
            if(Alice[i]&&Bob[i]) ans++;
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java 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();
        boolean[] Alice = new boolean[210];
        boolean[] Bob = new boolean[210];
        for(int i=A;i<B;i++) Alice[i] = true;
        for(int i=C;i<D;i++) Bob[i] = true;
        int ans = 0;
        for(int i=0;i<210;i++){
            if(Alice[i]&&Bob[i]) ans++;
        }
        System.out.println(ans);
    }
} 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();
        boolean[] Alice = new boolean[210];
        boolean[] Bob = new boolean[210];
        for(int i=A;i<B;i++) Alice[i] = true;
        for(int i=C;i<D;i++) Bob[i] = true;
        int ans = 0;
        for(int i=0;i<210;i++){
            if(Alice[i]&&Bob[i]) ans++;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        boolean[] Alice = new boolean[210];
        boolean[] Bob = new boolean[210];
        for(int i=A;i<B;i++) Alice[i] = true;
        for(int i=C;i<D;i++) Bob[i] = true;
        int ans = 0;
        for(int i=0;i<210;i++){
            if(Alice[i]&&Bob[i]) ans++;
        }
        System.out.println(ans);
    } 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 boolean[] Alice = new boolean[210]; Alice new boolean[210] 210 boolean[] Bob = new boolean[210]; Bob new boolean[210] 210 for(int i=A;i<B;i++) Alice[i] = true; int i=A; int i=A; i A i<B i B i++ i++ i Alice[i] = true; Alice[i] = true Alice[i] Alice i true for(int i=C;i<D;i++) Bob[i] = true; int i=C; int i=C; i C i<D i D i++ i++ i Bob[i] = true; Bob[i] = true Bob[i] Bob i true int ans = 0; ans 0 for(int i=0;i<210;i++){
            if(Alice[i]&&Bob[i]) ans++;
        } int i=0; int i=0; i 0 i<210 i 210 i++ i++ i {
            if(Alice[i]&&Bob[i]) ans++;
        } {
            if(Alice[i]&&Bob[i]) ans++;
        } if(Alice[i]&&Bob[i]) ans++; Alice[i]&&Bob[i] Alice[i] Alice i Bob[i] Bob i ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.*;

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();
        boolean[] Alice = new boolean[210];
        boolean[] Bob = new boolean[210];
        for(int i=A;i<B;i++) Alice[i] = true;
        for(int i=C;i<D;i++) Bob[i] = true;
        int ans = 0;
        for(int i=0;i<210;i++){
            if(Alice[i]&&Bob[i]) ans++;
        }
        System.out.println(ans);
    }
}
