import java.util.*;

public class Main {
    public static void  main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] time = new int[4];
        for(int i = 0; i < 4; i++) {
            time[i] = sc.nextInt();
        }
        
        if ((time[1] <= time[2]) || (time[3] <= time[0])) {
            System.out.println(0);
        } else if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        }
    }
} import java.util.*; util.* java public class Main {
    public static void  main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] time = new int[4];
        for(int i = 0; i < 4; i++) {
            time[i] = sc.nextInt();
        }
        
        if ((time[1] <= time[2]) || (time[3] <= time[0])) {
            System.out.println(0);
        } else if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        }
    }
} Main public static void  main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] time = new int[4];
        for(int i = 0; i < 4; i++) {
            time[i] = sc.nextInt();
        }
        
        if ((time[1] <= time[2]) || (time[3] <= time[0])) {
            System.out.println(0);
        } else if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        
        int[] time = new int[4];
        for(int i = 0; i < 4; i++) {
            time[i] = sc.nextInt();
        }
        
        if ((time[1] <= time[2]) || (time[3] <= time[0])) {
            System.out.println(0);
        } else if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] time = new int[4]; time new int[4] 4 for(int i = 0; i < 4; i++) {
            time[i] = sc.nextInt();
        } int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
            time[i] = sc.nextInt();
        } {
            time[i] = sc.nextInt();
        } time[i] = sc.nextInt() time[i] time i sc.nextInt() sc.nextInt sc if ((time[1] <= time[2]) || (time[3] <= time[0])) {
            System.out.println(0);
        } else if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        } (time[1] <= time[2]) || (time[3] <= time[0]) (time[1] <= time[2]) time[1] time 1 time[2] time 2 (time[3] <= time[0]) time[3] time 3 time[0] time 0 {
            System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        } time[0] <= time[2] time[0] time 0 time[2] time 2 {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            } time[3] <= time[1] time[3] time 3 time[1] time 1 {
                System.out.println(time[3] - time[2]);
            } System.out.println(time[3] - time[2]) System.out.println System.out System System.out time[3] - time[2] time[3] time 3 time[2] time 2 {
                System.out.println(time[1] - time[2]);
            } System.out.println(time[1] - time[2]) System.out.println System.out System System.out time[1] - time[2] time[1] time 1 time[2] time 2 if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        } time[0] > time[2] time[0] time 0 time[2] time 2 {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        } if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            } time[3] <= time[1] time[3] time 3 time[1] time 1 {
                System.out.println(time[3] - time[0]);
            } System.out.println(time[3] - time[0]) System.out.println System.out System System.out time[3] - time[0] time[3] time 3 time[0] time 0 {
                System.out.println(time[1] - time[0]);
            } System.out.println(time[1] - time[0]) System.out.println System.out System System.out time[1] - time[0] time[1] time 1 time[0] time 0 String[] args args public class Main {
    public static void  main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] time = new int[4];
        for(int i = 0; i < 4; i++) {
            time[i] = sc.nextInt();
        }
        
        if ((time[1] <= time[2]) || (time[3] <= time[0])) {
            System.out.println(0);
        } else if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        }
    }
} public class Main {
    public static void  main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] time = new int[4];
        for(int i = 0; i < 4; i++) {
            time[i] = sc.nextInt();
        }
        
        if ((time[1] <= time[2]) || (time[3] <= time[0])) {
            System.out.println(0);
        } else if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        }
    }
} Main
import java.util.*;

public class Main {
    public static void  main (String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int[] time = new int[4];
        for(int i = 0; i < 4; i++) {
            time[i] = sc.nextInt();
        }
        
        if ((time[1] <= time[2]) || (time[3] <= time[0])) {
            System.out.println(0);
        } else if (time[0] <= time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[2]);
            } else {
                System.out.println(time[1] - time[2]);
            }
        } else if (time[0] > time[2]) {
            if (time[3] <= time[1]) {
                System.out.println(time[3] - time[0]);
            } else {
                System.out.println(time[1] - time[0]);
            }
        }
    }
}