import java.util.Scanner;

public class Main
{
    int a, b, c, d;
    int ans = 0;
    
    public static void main(String args[])
    {
	new Main().run();
    }
    
    void run()
    {
	in();

	a = Math.max(a, c);
	b = Math.min(b, d);
	ans = b - a;
	
	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);

	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();
	d = sc.nextInt();
    }

    void out()
    {
	System.out.println(ans < 0 ? 0 : ans);
    }
} import java.util.Scanner; Scanner java.util public class Main
{
    int a, b, c, d;
    int ans = 0;
    
    public static void main(String args[])
    {
	new Main().run();
    }
    
    void run()
    {
	in();

	a = Math.max(a, c);
	b = Math.min(b, d);
	ans = b - a;
	
	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);

	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();
	d = sc.nextInt();
    }

    void out()
    {
	System.out.println(ans < 0 ? 0 : ans);
    }
} Main int a a b b c c d; d int ans = 0; ans 0 public static void main(String args[])
    {
	new Main().run();
    } main {
	new Main().run();
    } new Main().run() new Main().run new Main() String args[] args void run()
    {
	in();

	a = Math.max(a, c);
	b = Math.min(b, d);
	ans = b - a;
	
	out();
    } run {
	in();

	a = Math.max(a, c);
	b = Math.min(b, d);
	ans = b - a;
	
	out();
    } in() in a = Math.max(a, c) a Math.max(a, c) Math.max Math a c b = Math.min(b, d) b Math.min(b, d) Math.min Math b d ans = b - a ans b - a b a out() out void in()
    {
	Scanner sc = new Scanner(System.in);

	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();
	d = sc.nextInt();
    } in {
	Scanner sc = new Scanner(System.in);

	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();
	d = sc.nextInt();
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) a = sc.nextInt() a sc.nextInt() sc.nextInt sc b = sc.nextInt() b sc.nextInt() sc.nextInt sc c = sc.nextInt() c sc.nextInt() sc.nextInt sc d = sc.nextInt() d sc.nextInt() sc.nextInt sc void out()
    {
	System.out.println(ans < 0 ? 0 : ans);
    } out {
	System.out.println(ans < 0 ? 0 : ans);
    } System.out.println(ans < 0 ? 0 : ans) System.out.println System.out System System.out ans < 0 ? 0 : ans ans < 0 ans 0 0 ans public class Main
{
    int a, b, c, d;
    int ans = 0;
    
    public static void main(String args[])
    {
	new Main().run();
    }
    
    void run()
    {
	in();

	a = Math.max(a, c);
	b = Math.min(b, d);
	ans = b - a;
	
	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);

	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();
	d = sc.nextInt();
    }

    void out()
    {
	System.out.println(ans < 0 ? 0 : ans);
    }
} public class Main
{
    int a, b, c, d;
    int ans = 0;
    
    public static void main(String args[])
    {
	new Main().run();
    }
    
    void run()
    {
	in();

	a = Math.max(a, c);
	b = Math.min(b, d);
	ans = b - a;
	
	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);

	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();
	d = sc.nextInt();
    }

    void out()
    {
	System.out.println(ans < 0 ? 0 : ans);
    }
} Main
import java.util.Scanner;

public class Main
{
    int a, b, c, d;
    int ans = 0;
    
    public static void main(String args[])
    {
	new Main().run();
    }
    
    void run()
    {
	in();

	a = Math.max(a, c);
	b = Math.min(b, d);
	ans = b - a;
	
	out();
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);

	a = sc.nextInt();
	b = sc.nextInt();
	c = sc.nextInt();
	d = sc.nextInt();
    }

    void out()
    {
	System.out.println(ans < 0 ? 0 : ans);
    }
}
