import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int Alice_start = sc.nextInt();
        int Alice_end =sc.nextInt();
        int Bob_start =sc.nextInt();
        int Bob_end =sc.nextInt();
        int low = Math.max(Alice_start,Bob_start);
        int upp = Math.min(Alice_end,Bob_end);
        System.out.println(Math.max(0,upp-low));
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int Alice_start = sc.nextInt();
        int Alice_end =sc.nextInt();
        int Bob_start =sc.nextInt();
        int Bob_end =sc.nextInt();
        int low = Math.max(Alice_start,Bob_start);
        int upp = Math.min(Alice_end,Bob_end);
        System.out.println(Math.max(0,upp-low));
    }
} Main public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int Alice_start = sc.nextInt();
        int Alice_end =sc.nextInt();
        int Bob_start =sc.nextInt();
        int Bob_end =sc.nextInt();
        int low = Math.max(Alice_start,Bob_start);
        int upp = Math.min(Alice_end,Bob_end);
        System.out.println(Math.max(0,upp-low));
    } main {
        Scanner sc = new Scanner(System.in);
        int Alice_start = sc.nextInt();
        int Alice_end =sc.nextInt();
        int Bob_start =sc.nextInt();
        int Bob_end =sc.nextInt();
        int low = Math.max(Alice_start,Bob_start);
        int upp = Math.min(Alice_end,Bob_end);
        System.out.println(Math.max(0,upp-low));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int Alice_start = sc.nextInt(); Alice_start sc.nextInt() sc.nextInt sc int Alice_end =sc.nextInt(); Alice_end sc.nextInt() sc.nextInt sc int Bob_start =sc.nextInt(); Bob_start sc.nextInt() sc.nextInt sc int Bob_end =sc.nextInt(); Bob_end sc.nextInt() sc.nextInt sc int low = Math.max(Alice_start,Bob_start); low Math.max(Alice_start,Bob_start) Math.max Math Alice_start Bob_start int upp = Math.min(Alice_end,Bob_end); upp Math.min(Alice_end,Bob_end) Math.min Math Alice_end Bob_end System.out.println(Math.max(0,upp-low)) System.out.println System.out System System.out Math.max(0,upp-low) Math.max Math 0 upp-low upp low String [] args args public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int Alice_start = sc.nextInt();
        int Alice_end =sc.nextInt();
        int Bob_start =sc.nextInt();
        int Bob_end =sc.nextInt();
        int low = Math.max(Alice_start,Bob_start);
        int upp = Math.min(Alice_end,Bob_end);
        System.out.println(Math.max(0,upp-low));
    }
} public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int Alice_start = sc.nextInt();
        int Alice_end =sc.nextInt();
        int Bob_start =sc.nextInt();
        int Bob_end =sc.nextInt();
        int low = Math.max(Alice_start,Bob_start);
        int upp = Math.min(Alice_end,Bob_end);
        System.out.println(Math.max(0,upp-low));
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main (String [] args){
        Scanner sc = new Scanner(System.in);
        int Alice_start = sc.nextInt();
        int Alice_end =sc.nextInt();
        int Bob_start =sc.nextInt();
        int Bob_end =sc.nextInt();
        int low = Math.max(Alice_start,Bob_start);
        int upp = Math.min(Alice_end,Bob_end);
        System.out.println(Math.max(0,upp-low));
    }
}