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 max = Math.max(a, c);
    int min = Math.min(b, d);

	System.out.println(Math.max(0, min-max));
    }
} 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 max = Math.max(a, c);
    int min = Math.min(b, d);

	System.out.println(Math.max(0, min-max));
    }
} 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 max = Math.max(a, c);
    int min = Math.min(b, d);

	System.out.println(Math.max(0, min-max));
    } main {
    
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();

    int max = Math.max(a, c);
    int min = Math.min(b, d);

	System.out.println(Math.max(0, min-max));
    } 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 max = Math.max(a, c); max Math.max(a, c) Math.max Math a c int min = Math.min(b, d); min Math.min(b, d) Math.min Math b d System.out.println(Math.max(0, min-max)) System.out.println System.out System System.out Math.max(0, min-max) Math.max Math 0 min-max min max 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 max = Math.max(a, c);
    int min = Math.min(b, d);

	System.out.println(Math.max(0, min-max));
    }
} 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 max = Math.max(a, c);
    int min = Math.min(b, d);

	System.out.println(Math.max(0, min-max));
    }
} 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 max = Math.max(a, c);
    int min = Math.min(b, d);

	System.out.println(Math.max(0, min-max));
    }
}