import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        int start = A > C ? A : C;
        int end = B < D ? B : D;
        System.out.println(end - start > 0 ? end - start : 0);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        int start = A > C ? A : C;
        int end = B < D ? B : D;
        System.out.println(end - start > 0 ? end - start : 0);
    }
} Main Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) public static void main(String[] args) {
        new Main().compute();
    } main {
        new Main().compute();
    } new Main().compute() new Main().compute new Main() String[] args args void compute() {
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        int start = A > C ? A : C;
        int end = B < D ? B : D;
        System.out.println(end - start > 0 ? end - start : 0);
    } compute {
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        int start = A > C ? A : C;
        int end = B < D ? B : D;
        System.out.println(end - start > 0 ? end - start : 0);
    } int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner int C = scanner.nextInt(); C scanner.nextInt() scanner.nextInt scanner int D = scanner.nextInt(); D scanner.nextInt() scanner.nextInt scanner int start = A > C ? A : C; start A > C ? A : C A > C A C A C int end = B < D ? B : D; end B < D ? B : D B < D B D B D System.out.println(end - start > 0 ? end - start : 0) System.out.println System.out System System.out end - start > 0 ? end - start : 0 end - start > 0 end - start end start 0 end - start end start 0 public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        int start = A > C ? A : C;
        int end = B < D ? B : D;
        System.out.println(end - start > 0 ? end - start : 0);
    }
} public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        int start = A > C ? A : C;
        int end = B < D ? B : D;
        System.out.println(end - start > 0 ? end - start : 0);
    }
} Main
import java.util.Scanner;

public class Main {

    Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();
        int D = scanner.nextInt();
        int start = A > C ? A : C;
        int end = B < D ? B : D;
        System.out.println(end - start > 0 ? end - start : 0);
    }
}
