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 [] a = new int[101];
        for (int i = 0 ; i <= 100 ; i++) {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        }
        int ans = 0;
        for (int i = 0 ; i <= 100 ; i++) {
            if (a[i] == 2) {
                ans++;
            }
        }
        if (ans != 0) {
            System.out.println(ans - 1);
        } else {
            System.out.println(ans);
        }


    }
} 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 [] a = new int[101];
        for (int i = 0 ; i <= 100 ; i++) {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        }
        int ans = 0;
        for (int i = 0 ; i <= 100 ; i++) {
            if (a[i] == 2) {
                ans++;
            }
        }
        if (ans != 0) {
            System.out.println(ans - 1);
        } else {
            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();
        int [] a = new int[101];
        for (int i = 0 ; i <= 100 ; i++) {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        }
        int ans = 0;
        for (int i = 0 ; i <= 100 ; i++) {
            if (a[i] == 2) {
                ans++;
            }
        }
        if (ans != 0) {
            System.out.println(ans - 1);
        } else {
            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 [] a = new int[101];
        for (int i = 0 ; i <= 100 ; i++) {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        }
        int ans = 0;
        for (int i = 0 ; i <= 100 ; i++) {
            if (a[i] == 2) {
                ans++;
            }
        }
        if (ans != 0) {
            System.out.println(ans - 1);
        } else {
            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 [] a = new int[101]; a new int[101] 101 for (int i = 0 ; i <= 100 ; i++) {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        } int i = 0 ; int i = 0 ; i 0 i <= 100 i 100 i++ i++ i {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        } {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        } if (i >= A && i <= B) {
               a[i]++;
            } i >= A && i <= B i >= A i A i <= B i B {
               a[i]++;
            } a[i]++ a[i] a i if (i >= C && i <= D) {
                a[i]++;
            } i >= C && i <= D i >= C i C i <= D i D {
                a[i]++;
            } a[i]++ a[i] a i int ans = 0; ans 0 for (int i = 0 ; i <= 100 ; i++) {
            if (a[i] == 2) {
                ans++;
            }
        } int i = 0 ; int i = 0 ; i 0 i <= 100 i 100 i++ i++ i {
            if (a[i] == 2) {
                ans++;
            }
        } {
            if (a[i] == 2) {
                ans++;
            }
        } if (a[i] == 2) {
                ans++;
            } a[i] == 2 a[i] a i 2 {
                ans++;
            } ans++ ans if (ans != 0) {
            System.out.println(ans - 1);
        } else {
            System.out.println(ans);
        } ans != 0 ans 0 {
            System.out.println(ans - 1);
        } System.out.println(ans - 1) System.out.println System.out System System.out ans - 1 ans 1 {
            System.out.println(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) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int [] a = new int[101];
        for (int i = 0 ; i <= 100 ; i++) {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        }
        int ans = 0;
        for (int i = 0 ; i <= 100 ; i++) {
            if (a[i] == 2) {
                ans++;
            }
        }
        if (ans != 0) {
            System.out.println(ans - 1);
        } else {
            System.out.println(ans);
        }


    }
} 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 [] a = new int[101];
        for (int i = 0 ; i <= 100 ; i++) {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        }
        int ans = 0;
        for (int i = 0 ; i <= 100 ; i++) {
            if (a[i] == 2) {
                ans++;
            }
        }
        if (ans != 0) {
            System.out.println(ans - 1);
        } else {
            System.out.println(ans);
        }


    }
} 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 [] a = new int[101];
        for (int i = 0 ; i <= 100 ; i++) {
            if (i >= A && i <= B) {
               a[i]++;
            }
            if (i >= C && i <= D) {
                a[i]++;
            }
        }
        int ans = 0;
        for (int i = 0 ; i <= 100 ; i++) {
            if (a[i] == 2) {
                ans++;
            }
        }
        if (ans != 0) {
            System.out.println(ans - 1);
        } else {
            System.out.println(ans);
        }


    }
}
