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

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

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

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

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

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

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

        int cul = 0;
        if(min-max > 0) {
            cul = min-max;
        }
        System.out.println(cul);
    }
}