import 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 start = a > c ? a : c;
        int end = b < d ? b : d;

        int time = end - start > 0 ? end - start : 0;

        System.out.println(time);
    }
} import java.util.*; util.* java 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 start = a > c ? a : c;
        int end = b < d ? b : d;

        int time = end - start > 0 ? end - start : 0;

        System.out.println(time);
    }
} 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 start = a > c ? a : c;
        int end = b < d ? b : d;

        int time = end - start > 0 ? end - start : 0;

        System.out.println(time);
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int start = a > c ? a : c;
        int end = b < d ? b : d;

        int time = end - start > 0 ? end - start : 0;

        System.out.println(time);
    } 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 start = a > c ? a : c; start a > c ? a : c a > c a c a c int end = b < d ? b : d; end b < d ? b : d b < d b d b d int time = end - start > 0 ? end - start : 0; time end - start > 0 ? end - start : 0 end - start > 0 end - start end start 0 end - start end start 0 System.out.println(time) System.out.println System.out System System.out time 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 start = a > c ? a : c;
        int end = b < d ? b : d;

        int time = end - start > 0 ? end - start : 0;

        System.out.println(time);
    }
} 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 start = a > c ? a : c;
        int end = b < d ? b : d;

        int time = end - start > 0 ? end - start : 0;

        System.out.println(time);
    }
} Main
import 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 start = a > c ? a : c;
        int end = b < d ? b : d;

        int time = end - start > 0 ? end - start : 0;

        System.out.println(time);
    }
}