import java.util.Scanner;
import java.util.StringJoiner;

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();

        if (c > b || a > d) {
            System.out.println(0);
            return;
        }
        int start;
        int end;
        if (a > c) {
            start = a;
        } else {
            start = c;
        }
        if (b > d) {
            end = d;
        } else {
            end = b;
        }
        System.out.println(end - start);
    }

} import java.util.Scanner; Scanner java.util import java.util.StringJoiner; StringJoiner 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();

        if (c > b || a > d) {
            System.out.println(0);
            return;
        }
        int start;
        int end;
        if (a > c) {
            start = a;
        } else {
            start = c;
        }
        if (b > d) {
            end = d;
        } else {
            end = b;
        }
        System.out.println(end - start);
    }

} 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();

        if (c > b || a > d) {
            System.out.println(0);
            return;
        }
        int start;
        int end;
        if (a > c) {
            start = a;
        } else {
            start = c;
        }
        if (b > d) {
            end = d;
        } else {
            end = b;
        }
        System.out.println(end - start);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if (c > b || a > d) {
            System.out.println(0);
            return;
        }
        int start;
        int end;
        if (a > c) {
            start = a;
        } else {
            start = c;
        }
        if (b > d) {
            end = d;
        } else {
            end = b;
        }
        System.out.println(end - start);
    } 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 if (c > b || a > d) {
            System.out.println(0);
            return;
        } c > b || a > d c > b c b a > d a d {
            System.out.println(0);
            return;
        } System.out.println(0) System.out.println System.out System System.out 0 return; int start; start int end; end if (a > c) {
            start = a;
        } else {
            start = c;
        } a > c a c {
            start = a;
        } start = a start a {
            start = c;
        } start = c start c if (b > d) {
            end = d;
        } else {
            end = b;
        } b > d b d {
            end = d;
        } end = d end d {
            end = b;
        } end = b end b System.out.println(end - start) System.out.println System.out System System.out end - start end start 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();

        if (c > b || a > d) {
            System.out.println(0);
            return;
        }
        int start;
        int end;
        if (a > c) {
            start = a;
        } else {
            start = c;
        }
        if (b > d) {
            end = d;
        } else {
            end = b;
        }
        System.out.println(end - start);
    }

} 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();

        if (c > b || a > d) {
            System.out.println(0);
            return;
        }
        int start;
        int end;
        if (a > c) {
            start = a;
        } else {
            start = c;
        }
        if (b > d) {
            end = d;
        } else {
            end = b;
        }
        System.out.println(end - start);
    }

} Main
import java.util.Scanner;
import java.util.StringJoiner;

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();

        if (c > b || a > d) {
            System.out.println(0);
            return;
        }
        int start;
        int end;
        if (a > c) {
            start = a;
        } else {
            start = c;
        }
        if (b > d) {
            end = d;
        } else {
            end = b;
        }
        System.out.println(end - start);
    }

}
