import java.util.*;

public class Main {
//    private static final String ex = "0 75 25 100";
    private static final String ex = "10 90 20 80";

    public static void main(String[] args) {
        System.out.println(solve(new Scanner(System.in)));
//        System.out.println(solve(new Scanner(ex)));
    }

    private static int solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");

        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int C = Integer.parseInt(split[2]);
        int D = Integer.parseInt(split[3]);

        if (B <= C || D <= A) return 0;
        else if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException();
    }
} import java.util.*; util.* java public class Main {
//    private static final String ex = "0 75 25 100";
    private static final String ex = "10 90 20 80";

    public static void main(String[] args) {
        System.out.println(solve(new Scanner(System.in)));
//        System.out.println(solve(new Scanner(ex)));
    }

    private static int solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");

        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int C = Integer.parseInt(split[2]);
        int D = Integer.parseInt(split[3]);

        if (B <= C || D <= A) return 0;
        else if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException();
    }
} Main //    private static final String ex = "0 75 25 100";
    private static final String ex = "10 90 20 80"; ex "10 90 20 80" public static void main(String[] args) {
        System.out.println(solve(new Scanner(System.in)));
//        System.out.println(solve(new Scanner(ex)));
    } main {
        System.out.println(solve(new Scanner(System.in)));
//        System.out.println(solve(new Scanner(ex)));
    } System.out.println(solve(new Scanner(System.in))) System.out.println System.out System System.out solve(new Scanner(System.in)) solve new Scanner(System.in) String[] args args private static int solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");

        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int C = Integer.parseInt(split[2]);
        int D = Integer.parseInt(split[3]);

        if (B <= C || D <= A) return 0;
        else if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException();
    } solve {
        String[] split = scanner.nextLine().split(" ");

        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int C = Integer.parseInt(split[2]);
        int D = Integer.parseInt(split[3]);

        if (B <= C || D <= A) return 0;
        else if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException();
    } String[] split = scanner.nextLine().split(" "); split scanner.nextLine().split(" ") scanner.nextLine().split scanner.nextLine() scanner.nextLine scanner " " int A = Integer.parseInt(split[0]); A Integer.parseInt(split[0]) Integer.parseInt Integer split[0] split 0 int B = Integer.parseInt(split[1]); B Integer.parseInt(split[1]) Integer.parseInt Integer split[1] split 1 int C = Integer.parseInt(split[2]); C Integer.parseInt(split[2]) Integer.parseInt Integer split[2] split 2 int D = Integer.parseInt(split[3]); D Integer.parseInt(split[3]) Integer.parseInt Integer split[3] split 3 if (B <= C || D <= A) return 0;
        else if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException(); B <= C || D <= A B <= C B C D <= A D A return 0; 0 if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException(); C <= A && B <= D C <= A C A B <= D B D return B - A; B - A B A if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException(); A <= C && D <= B A <= C A C D <= B D B return D - C; D - C D C if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException(); A <= C A C return B - C; B - C B C if (C <= A) return D - A;
        else throw new RuntimeException(); C <= A C A return D - A; D - A D A throw new RuntimeException(); new RuntimeException() Scanner scanner scanner public class Main {
//    private static final String ex = "0 75 25 100";
    private static final String ex = "10 90 20 80";

    public static void main(String[] args) {
        System.out.println(solve(new Scanner(System.in)));
//        System.out.println(solve(new Scanner(ex)));
    }

    private static int solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");

        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int C = Integer.parseInt(split[2]);
        int D = Integer.parseInt(split[3]);

        if (B <= C || D <= A) return 0;
        else if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException();
    }
} public class Main {
//    private static final String ex = "0 75 25 100";
    private static final String ex = "10 90 20 80";

    public static void main(String[] args) {
        System.out.println(solve(new Scanner(System.in)));
//        System.out.println(solve(new Scanner(ex)));
    }

    private static int solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");

        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int C = Integer.parseInt(split[2]);
        int D = Integer.parseInt(split[3]);

        if (B <= C || D <= A) return 0;
        else if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException();
    }
} Main
import java.util.*;

public class Main {
//    private static final String ex = "0 75 25 100";
    private static final String ex = "10 90 20 80";

    public static void main(String[] args) {
        System.out.println(solve(new Scanner(System.in)));
//        System.out.println(solve(new Scanner(ex)));
    }

    private static int solve(Scanner scanner) {
        String[] split = scanner.nextLine().split(" ");

        int A = Integer.parseInt(split[0]);
        int B = Integer.parseInt(split[1]);
        int C = Integer.parseInt(split[2]);
        int D = Integer.parseInt(split[3]);

        if (B <= C || D <= A) return 0;
        else if (C <= A && B <= D) return B - A;
        else if (A <= C && D <= B) return D - C;
        else if (A <= C) return B - C;
        else if (C <= A) return D - A;
        else throw new RuntimeException();
    }
}
