import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static boolean found = false;

    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 minSec = Integer.MAX_VALUE;
        int maxSec = 0;

        for (int i = 0; i < 101; i++) {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        }

        if (minSec == Integer.MAX_VALUE) {
            System.out.println("0");
        } else {
            System.out.println(maxSec - minSec);
        }
    }

} import java.util.*; util.* java import java.util.stream.IntStream; IntStream java.util.stream public class Main {

    public static boolean found = false;

    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 minSec = Integer.MAX_VALUE;
        int maxSec = 0;

        for (int i = 0; i < 101; i++) {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        }

        if (minSec == Integer.MAX_VALUE) {
            System.out.println("0");
        } else {
            System.out.println(maxSec - minSec);
        }
    }

} Main public static boolean found = false; found false 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 minSec = Integer.MAX_VALUE;
        int maxSec = 0;

        for (int i = 0; i < 101; i++) {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        }

        if (minSec == Integer.MAX_VALUE) {
            System.out.println("0");
        } else {
            System.out.println(maxSec - minSec);
        }
    } main {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int minSec = Integer.MAX_VALUE;
        int maxSec = 0;

        for (int i = 0; i < 101; i++) {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        }

        if (minSec == Integer.MAX_VALUE) {
            System.out.println("0");
        } else {
            System.out.println(maxSec - minSec);
        }
    } 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 minSec = Integer.MAX_VALUE; minSec Integer.MAX_VALUE Integer Integer.MAX_VALUE int maxSec = 0; maxSec 0 for (int i = 0; i < 101; i++) {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        } int i = 0; int i = 0; i 0 i < 101 i 101 i++ i++ i {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        } {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        } boolean alice = (a <= i && i <= b); alice (a <= i && i <= b) a <= i a i i <= b i b boolean bob = (c <= i && i <= d); bob (c <= i && i <= d) c <= i c i i <= d i d if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            } alice && bob alice bob {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            } maxSec = Math.max(maxSec, i) maxSec Math.max(maxSec, i) Math.max Math maxSec i minSec = Math.min(minSec, i) minSec Math.min(minSec, i) Math.min Math minSec i if (minSec == Integer.MAX_VALUE) {
            System.out.println("0");
        } else {
            System.out.println(maxSec - minSec);
        } minSec == Integer.MAX_VALUE minSec Integer.MAX_VALUE Integer Integer.MAX_VALUE {
            System.out.println("0");
        } System.out.println("0") System.out.println System.out System System.out "0" {
            System.out.println(maxSec - minSec);
        } System.out.println(maxSec - minSec) System.out.println System.out System System.out maxSec - minSec maxSec minSec String[] args args public class Main {

    public static boolean found = false;

    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 minSec = Integer.MAX_VALUE;
        int maxSec = 0;

        for (int i = 0; i < 101; i++) {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        }

        if (minSec == Integer.MAX_VALUE) {
            System.out.println("0");
        } else {
            System.out.println(maxSec - minSec);
        }
    }

} public class Main {

    public static boolean found = false;

    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 minSec = Integer.MAX_VALUE;
        int maxSec = 0;

        for (int i = 0; i < 101; i++) {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        }

        if (minSec == Integer.MAX_VALUE) {
            System.out.println("0");
        } else {
            System.out.println(maxSec - minSec);
        }
    }

} Main
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static boolean found = false;

    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 minSec = Integer.MAX_VALUE;
        int maxSec = 0;

        for (int i = 0; i < 101; i++) {
            boolean alice = (a <= i && i <= b);
            boolean bob = (c <= i && i <= d);

            if (alice && bob) {
                maxSec = Math.max(maxSec, i);
                minSec = Math.min(minSec, i);
            }
        }

        if (minSec == Integer.MAX_VALUE) {
            System.out.println("0");
        } else {
            System.out.println(maxSec - minSec);
        }
    }

}