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();
        if(a < c){
            a = c;
        }
        if(b > d){
            b = d;
        }
        if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        }
    }
} 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();
        if(a < c){
            a = c;
        }
        if(b > d){
            b = d;
        }
        if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        }
    }
} 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();
        if(a < c){
            a = c;
        }
        if(b > d){
            b = d;
        }
        if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        if(a < c){
            a = c;
        }
        if(b > d){
            b = d;
        }
        if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        }
    } 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 if(a < c){
            a = c;
        } a < c a c {
            a = c;
        } a = c a c if(b > d){
            b = d;
        } b > d b d {
            b = d;
        } b = d b d if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        } b < a b a {
            System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 {
            System.out.println(b - a);
        } System.out.println(b - a) System.out.println System.out System System.out b - a b a 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();
        if(a < c){
            a = c;
        }
        if(b > d){
            b = d;
        }
        if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        }
    }
} 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();
        if(a < c){
            a = c;
        }
        if(b > d){
            b = d;
        }
        if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        }
    }
} 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();
        if(a < c){
            a = c;
        }
        if(b > d){
            b = d;
        }
        if(b < a){
            System.out.println(0);
        }else{
            System.out.println(b - a);
        }
    }
}