import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int[] array = new int[101];
        for (int i = a; i < b; i++) {
            array[i]++;
        }
        for (int i = c; i < d; i++) {
            array[i]++;
        }
        int ans = 0;
        for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                ans++;
            }
        }
        System.out.println(ans);
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int[] array = new int[101];
        for (int i = a; i < b; i++) {
            array[i]++;
        }
        for (int i = c; i < d; i++) {
            array[i]++;
        }
        int ans = 0;
        for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                ans++;
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int[] array = new int[101];
        for (int i = a; i < b; i++) {
            array[i]++;
        }
        for (int i = c; i < d; i++) {
            array[i]++;
        }
        int ans = 0;
        for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                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();
        int[] array = new int[101];
        for (int i = a; i < b; i++) {
            array[i]++;
        }
        for (int i = c; i < d; i++) {
            array[i]++;
        }
        int ans = 0;
        for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                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 int[] array = new int[101]; array new int[101] 101 for (int i = a; i < b; i++) {
            array[i]++;
        } int i = a; int i = a; i a i < b i b i++ i++ i {
            array[i]++;
        } {
            array[i]++;
        } array[i]++ array[i] array i for (int i = c; i < d; i++) {
            array[i]++;
        } int i = c; int i = c; i c i < d i d i++ i++ i {
            array[i]++;
        } {
            array[i]++;
        } array[i]++ array[i] array i int ans = 0; ans 0 for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                ans++;
            }
        } int i = 0; int i = 0; i 0 i < 101 i 101 i++ i++ i {
            if (array[i] == 2) {
                ans++;
            }
        } {
            if (array[i] == 2) {
                ans++;
            }
        } if (array[i] == 2) {
                ans++;
            } array[i] == 2 array[i] array i 2 {
                ans++;
            } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int[] array = new int[101];
        for (int i = a; i < b; i++) {
            array[i]++;
        }
        for (int i = c; i < d; i++) {
            array[i]++;
        }
        int ans = 0;
        for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                ans++;
            }
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int[] array = new int[101];
        for (int i = a; i < b; i++) {
            array[i]++;
        }
        for (int i = c; i < d; i++) {
            array[i]++;
        }
        int ans = 0;
        for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                ans++;
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int[] array = new int[101];
        for (int i = a; i < b; i++) {
            array[i]++;
        }
        for (int i = c; i < d; i++) {
            array[i]++;
        }
        int ans = 0;
        for (int i = 0; i < 101; i++) {
            if (array[i] == 2) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}
