import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int [2];
        int[] b = new int [2];
        for(int i = 0;i < 2;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < 2;i++){
            b[i] = sc.nextInt();
        }
        int ans = Math.min(a[1],b[1]) - Math.max(a[0],b[0]);
        if(ans <= 0){
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int [2];
        int[] b = new int [2];
        for(int i = 0;i < 2;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < 2;i++){
            b[i] = sc.nextInt();
        }
        int ans = Math.min(a[1],b[1]) - Math.max(a[0],b[0]);
        if(ans <= 0){
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int [2];
        int[] b = new int [2];
        for(int i = 0;i < 2;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < 2;i++){
            b[i] = sc.nextInt();
        }
        int ans = Math.min(a[1],b[1]) - Math.max(a[0],b[0]);
        if(ans <= 0){
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int[] a = new int [2];
        int[] b = new int [2];
        for(int i = 0;i < 2;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < 2;i++){
            b[i] = sc.nextInt();
        }
        int ans = Math.min(a[1],b[1]) - Math.max(a[0],b[0]);
        if(ans <= 0){
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] a = new int [2]; a new int [2] 2 int[] b = new int [2]; b new int [2] 2 for(int i = 0;i < 2;i++){
            a[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < 2 i 2 i++ i++ i {
            a[i] = sc.nextInt();
        } {
            a[i] = sc.nextInt();
        } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc for(int i = 0;i < 2;i++){
            b[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < 2 i 2 i++ i++ i {
            b[i] = sc.nextInt();
        } {
            b[i] = sc.nextInt();
        } b[i] = sc.nextInt() b[i] b i sc.nextInt() sc.nextInt sc int ans = Math.min(a[1],b[1]) - Math.max(a[0],b[0]); ans Math.min(a[1],b[1]) - Math.max(a[0],b[0]) Math.min(a[1],b[1]) Math.min Math a[1] a 1 b[1] b 1 Math.max(a[0],b[0]) Math.max Math a[0] a 0 b[0] b 0 if(ans <= 0){
            System.out.println(0);
            return;
        } ans <= 0 ans 0 {
            System.out.println(0);
            return;
        } System.out.println(0) System.out.println System.out System System.out 0 return; System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int [2];
        int[] b = new int [2];
        for(int i = 0;i < 2;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < 2;i++){
            b[i] = sc.nextInt();
        }
        int ans = Math.min(a[1],b[1]) - Math.max(a[0],b[0]);
        if(ans <= 0){
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    }
} public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int [2];
        int[] b = new int [2];
        for(int i = 0;i < 2;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < 2;i++){
            b[i] = sc.nextInt();
        }
        int ans = Math.min(a[1],b[1]) - Math.max(a[0],b[0]);
        if(ans <= 0){
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    }
} Main
import java.util.Scanner;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] a = new int [2];
        int[] b = new int [2];
        for(int i = 0;i < 2;i++){
            a[i] = sc.nextInt();
        }
        for(int i = 0;i < 2;i++){
            b[i] = sc.nextInt();
        }
        int ans = Math.min(a[1],b[1]) - Math.max(a[0],b[0]);
        if(ans <= 0){
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    }
}
