
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int min,max;
        if(a>c){
            min = a;
        } else {
            min = c;
        }
        if(b < d){
            max = b;
        } else {
            max = d;
        }
        int ans = max-min;
        if(ans < 0)ans = 0;
        System.out.print(ans);
           
    }
    
} import java.util.Scanner; Scanner java.util public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int min,max;
        if(a>c){
            min = a;
        } else {
            min = c;
        }
        if(b < d){
            max = b;
        } else {
            max = d;
        }
        int ans = max-min;
        if(ans < 0)ans = 0;
        System.out.print(ans);
           
    }
    
} Main /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int min,max;
        if(a>c){
            min = a;
        } else {
            min = c;
        }
        if(b < d){
            max = b;
        } else {
            max = d;
        }
        int ans = max-min;
        if(ans < 0)ans = 0;
        System.out.print(ans);
           
    } main {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int min,max;
        if(a>c){
            min = a;
        } else {
            min = c;
        }
        if(b < d){
            max = b;
        } else {
            max = d;
        }
        int ans = max-min;
        if(ans < 0)ans = 0;
        System.out.print(ans);
           
    } 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 min min max; max if(a>c){
            min = a;
        } else {
            min = c;
        } a>c a c {
            min = a;
        } min = a min a {
            min = c;
        } min = c min c if(b < d){
            max = b;
        } else {
            max = d;
        } b < d b d {
            max = b;
        } max = b max b {
            max = d;
        } max = d max d int ans = max-min; ans max-min max min if(ans < 0)ans = 0; ans < 0 ans 0 ans = 0 ans 0 System.out.print(ans) System.out.print System.out System System.out ans String[] args args public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int min,max;
        if(a>c){
            min = a;
        } else {
            min = c;
        }
        if(b < d){
            max = b;
        } else {
            max = d;
        }
        int ans = max-min;
        if(ans < 0)ans = 0;
        System.out.print(ans);
           
    }
    
} public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int min,max;
        if(a>c){
            min = a;
        } else {
            min = c;
        }
        if(b < d){
            max = b;
        } else {
            max = d;
        }
        int ans = max-min;
        if(ans < 0)ans = 0;
        System.out.print(ans);
           
    }
    
} Main

import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int min,max;
        if(a>c){
            min = a;
        } else {
            min = c;
        }
        if(b < d){
            max = b;
        } else {
            max = d;
        }
        int ans = max-min;
        if(ans < 0)ans = 0;
        System.out.print(ans);
           
    }
    
}
