import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[4];
        for (int i = 0; i < nums.length; i++)
            nums[i] = sc.nextInt();
        if (nums[2] > nums[1] || nums[3] < nums[0]) {
            System.out.println(0);
            return;
        }
        Arrays.sort(nums);
        System.out.println(nums[2] - nums[1]);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[4];
        for (int i = 0; i < nums.length; i++)
            nums[i] = sc.nextInt();
        if (nums[2] > nums[1] || nums[3] < nums[0]) {
            System.out.println(0);
            return;
        }
        Arrays.sort(nums);
        System.out.println(nums[2] - nums[1]);
    }
} Main public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[4];
        for (int i = 0; i < nums.length; i++)
            nums[i] = sc.nextInt();
        if (nums[2] > nums[1] || nums[3] < nums[0]) {
            System.out.println(0);
            return;
        }
        Arrays.sort(nums);
        System.out.println(nums[2] - nums[1]);
    } main {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[4];
        for (int i = 0; i < nums.length; i++)
            nums[i] = sc.nextInt();
        if (nums[2] > nums[1] || nums[3] < nums[0]) {
            System.out.println(0);
            return;
        }
        Arrays.sort(nums);
        System.out.println(nums[2] - nums[1]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] nums = new int[4]; nums new int[4] 4 for (int i = 0; i < nums.length; i++)
            nums[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < nums.length i nums.length nums nums.length i++ i++ i nums[i] = sc.nextInt(); nums[i] = sc.nextInt() nums[i] nums i sc.nextInt() sc.nextInt sc if (nums[2] > nums[1] || nums[3] < nums[0]) {
            System.out.println(0);
            return;
        } nums[2] > nums[1] || nums[3] < nums[0] nums[2] > nums[1] nums[2] nums 2 nums[1] nums 1 nums[3] < nums[0] nums[3] nums 3 nums[0] nums 0 {
            System.out.println(0);
            return;
        } System.out.println(0) System.out.println System.out System System.out 0 return; Arrays.sort(nums) Arrays.sort Arrays nums System.out.println(nums[2] - nums[1]) System.out.println System.out System System.out nums[2] - nums[1] nums[2] nums 2 nums[1] nums 1 String args[] args public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[4];
        for (int i = 0; i < nums.length; i++)
            nums[i] = sc.nextInt();
        if (nums[2] > nums[1] || nums[3] < nums[0]) {
            System.out.println(0);
            return;
        }
        Arrays.sort(nums);
        System.out.println(nums[2] - nums[1]);
    }
} public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[4];
        for (int i = 0; i < nums.length; i++)
            nums[i] = sc.nextInt();
        if (nums[2] > nums[1] || nums[3] < nums[0]) {
            System.out.println(0);
            return;
        }
        Arrays.sort(nums);
        System.out.println(nums[2] - nums[1]);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int[] nums = new int[4];
        for (int i = 0; i < nums.length; i++)
            nums[i] = sc.nextInt();
        if (nums[2] > nums[1] || nums[3] < nums[0]) {
            System.out.println(0);
            return;
        }
        Arrays.sort(nums);
        System.out.println(nums[2] - nums[1]);
    }
}
