import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        }catch(Exception e){
            
        }
    }
} import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        }catch(Exception e){
            
        }
    }
} Main public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        }catch(Exception e){
            
        }
    } main {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        }catch(Exception e){
            
        }
    } try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        }catch(Exception e){
            
        } catch(Exception e){
            
        } Exception e {
            
        } {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String strSplit[] = br.readLine().split(" "); strSplit br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int A = Integer.parseInt(strSplit[0]); A Integer.parseInt(strSplit[0]) Integer.parseInt Integer strSplit[0] strSplit 0 int B = Integer.parseInt(strSplit[1]); B Integer.parseInt(strSplit[1]) Integer.parseInt Integer strSplit[1] strSplit 1 int C = Integer.parseInt(strSplit[2]); C Integer.parseInt(strSplit[2]) Integer.parseInt Integer strSplit[2] strSplit 2 int D = Integer.parseInt(strSplit[3]); D Integer.parseInt(strSplit[3]) Integer.parseInt Integer strSplit[3] strSplit 3 int AC = Math.max(A, C); AC Math.max(A, C) Math.max Math A C int BD = Math.min(B, D); BD Math.min(B, D) Math.min Math B D if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            } BD > AC BD AC {
                System.out.println(BD-AC);
            } System.out.println(BD-AC) System.out.println System.out System System.out BD-AC BD AC {
                System.out.println("0");
            } System.out.println("0") System.out.println System.out System System.out "0" String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        }catch(Exception e){
            
        }
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        }catch(Exception e){
            
        }
    }
} Main
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            int A = Integer.parseInt(strSplit[0]);
            int B = Integer.parseInt(strSplit[1]);
            int C = Integer.parseInt(strSplit[2]);
            int D = Integer.parseInt(strSplit[3]);
            
            int AC = Math.max(A, C);
            int BD = Math.min(B, D);
            
            if(BD > AC){
                System.out.println(BD-AC);
            }else{
                System.out.println("0");
            }
            
        }catch(Exception e){
            
        }
    }
}