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 start = 0;
        int end = 100;
        int res = 0;

        if(a <= c){
            start = c;
        } else {
            start = a;
        }

        if(b <= d){
            end = b;
        } else {
            end = d;
        }

        res = end - start;
        if(res < 0){
            res = 0;
        }

        System.out.println(res);
        sc.close();
    }

} 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 start = 0;
        int end = 100;
        int res = 0;

        if(a <= c){
            start = c;
        } else {
            start = a;
        }

        if(b <= d){
            end = b;
        } else {
            end = d;
        }

        res = end - start;
        if(res < 0){
            res = 0;
        }

        System.out.println(res);
        sc.close();
    }

} 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 start = 0;
        int end = 100;
        int res = 0;

        if(a <= c){
            start = c;
        } else {
            start = a;
        }

        if(b <= d){
            end = b;
        } else {
            end = d;
        }

        res = end - start;
        if(res < 0){
            res = 0;
        }

        System.out.println(res);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int start = 0;
        int end = 100;
        int res = 0;

        if(a <= c){
            start = c;
        } else {
            start = a;
        }

        if(b <= d){
            end = b;
        } else {
            end = d;
        }

        res = end - start;
        if(res < 0){
            res = 0;
        }

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

        if(a <= c){
            start = c;
        } else {
            start = a;
        }

        if(b <= d){
            end = b;
        } else {
            end = d;
        }

        res = end - start;
        if(res < 0){
            res = 0;
        }

        System.out.println(res);
        sc.close();
    }

} 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 start = 0;
        int end = 100;
        int res = 0;

        if(a <= c){
            start = c;
        } else {
            start = a;
        }

        if(b <= d){
            end = b;
        } else {
            end = d;
        }

        res = end - start;
        if(res < 0){
            res = 0;
        }

        System.out.println(res);
        sc.close();
    }

} 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 start = 0;
        int end = 100;
        int res = 0;

        if(a <= c){
            start = c;
        } else {
            start = a;
        }

        if(b <= d){
            end = b;
        } else {
            end = d;
        }

        res = end - start;
        if(res < 0){
            res = 0;
        }

        System.out.println(res);
        sc.close();
    }

}