import java.util.Scanner;

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[] ab = new int[100+1];
        int[] cd = new int[100+1];
        for (int i = a; i <= b; i++) {
            ab[i] = 1;
        }
        for (int i = c; i <= d; i++) {
            cd[i] = 1;
        }

        int e = 0;
        for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        }
        if (e >= 1) {
            e -= 1;
        }

        System.out.println(e);
    }

} import java.util.Scanner; Scanner 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[] ab = new int[100+1];
        int[] cd = new int[100+1];
        for (int i = a; i <= b; i++) {
            ab[i] = 1;
        }
        for (int i = c; i <= d; i++) {
            cd[i] = 1;
        }

        int e = 0;
        for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        }
        if (e >= 1) {
            e -= 1;
        }

        System.out.println(e);
    }

} 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[] ab = new int[100+1];
        int[] cd = new int[100+1];
        for (int i = a; i <= b; i++) {
            ab[i] = 1;
        }
        for (int i = c; i <= d; i++) {
            cd[i] = 1;
        }

        int e = 0;
        for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        }
        if (e >= 1) {
            e -= 1;
        }

        System.out.println(e);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int[] ab = new int[100+1];
        int[] cd = new int[100+1];
        for (int i = a; i <= b; i++) {
            ab[i] = 1;
        }
        for (int i = c; i <= d; i++) {
            cd[i] = 1;
        }

        int e = 0;
        for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        }
        if (e >= 1) {
            e -= 1;
        }

        System.out.println(e);
    } 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[] ab = new int[100+1]; ab new int[100+1] 100+1 100 1 int[] cd = new int[100+1]; cd new int[100+1] 100+1 100 1 for (int i = a; i <= b; i++) {
            ab[i] = 1;
        } int i = a; int i = a; i a i <= b i b i++ i++ i {
            ab[i] = 1;
        } {
            ab[i] = 1;
        } ab[i] = 1 ab[i] ab i 1 for (int i = c; i <= d; i++) {
            cd[i] = 1;
        } int i = c; int i = c; i c i <= d i d i++ i++ i {
            cd[i] = 1;
        } {
            cd[i] = 1;
        } cd[i] = 1 cd[i] cd i 1 int e = 0; e 0 for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        } int i = 0; int i = 0; i 0 i <= 100 i 100 i++ i++ i {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        } {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        } if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            } ab[i] == 1 && cd[i] == 1 ab[i] == 1 ab[i] ab i 1 cd[i] == 1 cd[i] cd i 1 {
                e += 1;
            } e += 1 e 1 if (e >= 1) {
            e -= 1;
        } e >= 1 e 1 {
            e -= 1;
        } e -= 1 e 1 System.out.println(e) System.out.println System.out System System.out e 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[] ab = new int[100+1];
        int[] cd = new int[100+1];
        for (int i = a; i <= b; i++) {
            ab[i] = 1;
        }
        for (int i = c; i <= d; i++) {
            cd[i] = 1;
        }

        int e = 0;
        for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        }
        if (e >= 1) {
            e -= 1;
        }

        System.out.println(e);
    }

} 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[] ab = new int[100+1];
        int[] cd = new int[100+1];
        for (int i = a; i <= b; i++) {
            ab[i] = 1;
        }
        for (int i = c; i <= d; i++) {
            cd[i] = 1;
        }

        int e = 0;
        for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        }
        if (e >= 1) {
            e -= 1;
        }

        System.out.println(e);
    }

} Main
import java.util.Scanner;

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[] ab = new int[100+1];
        int[] cd = new int[100+1];
        for (int i = a; i <= b; i++) {
            ab[i] = 1;
        }
        for (int i = c; i <= d; i++) {
            cd[i] = 1;
        }

        int e = 0;
        for (int i = 0; i <= 100; i++) {
            if (ab[i] == 1 && cd[i] == 1) {
                e += 1;
            }
        }
        if (e >= 1) {
            e -= 1;
        }

        System.out.println(e);
    }

}