import java.util.*;
import java.util.stream.Collectors;

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 result = 0;
        int lowwer = 0;
        int upper = 0;

        if (a >= c) {
            lowwer = a;
        } else {
            lowwer = c;
        }

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

        if (upper >= lowwer) {
            result = upper - lowwer;
        }

        System.out.println(result);
    }
} import java.util.*; util.* java import java.util.stream.Collectors; Collectors java.util.stream 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 result = 0;
        int lowwer = 0;
        int upper = 0;

        if (a >= c) {
            lowwer = a;
        } else {
            lowwer = c;
        }

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

        if (upper >= lowwer) {
            result = upper - lowwer;
        }

        System.out.println(result);
    }
} 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 result = 0;
        int lowwer = 0;
        int upper = 0;

        if (a >= c) {
            lowwer = a;
        } else {
            lowwer = c;
        }

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

        if (upper >= lowwer) {
            result = upper - lowwer;
        }

        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
      
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int result = 0;
        int lowwer = 0;
        int upper = 0;

        if (a >= c) {
            lowwer = a;
        } else {
            lowwer = c;
        }

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

        if (upper >= lowwer) {
            result = upper - lowwer;
        }

        System.out.println(result);
    } 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 result = 0; result 0 int lowwer = 0; lowwer 0 int upper = 0; upper 0 if (a >= c) {
            lowwer = a;
        } else {
            lowwer = c;
        } a >= c a c {
            lowwer = a;
        } lowwer = a lowwer a {
            lowwer = c;
        } lowwer = c lowwer c if (b <= d) {
            upper = b;
        } else {
            upper = d;
        } b <= d b d {
            upper = b;
        } upper = b upper b {
            upper = d;
        } upper = d upper d if (upper >= lowwer) {
            result = upper - lowwer;
        } upper >= lowwer upper lowwer {
            result = upper - lowwer;
        } result = upper - lowwer result upper - lowwer upper lowwer System.out.println(result) System.out.println System.out System System.out result String args[] args
import java.util.*;
import java.util.stream.Collectors;

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 result = 0;
        int lowwer = 0;
        int upper = 0;

        if (a >= c) {
            lowwer = a;
        } else {
            lowwer = c;
        }

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

        if (upper >= lowwer) {
            result = upper - lowwer;
        }

        System.out.println(result);
    }
}