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){
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        }
        if(b < c){
            System.out.println(0);
        }
        else if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        }
	}
} 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){
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        }
        if(b < c){
            System.out.println(0);
        }
        else if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        }
	}
} 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){
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        }
        if(b < c){
            System.out.println(0);
        }
        else if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        }
	} 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){
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        }
        if(b < c){
            System.out.println(0);
        }
        else if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        }
	} 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){
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        } a>c a c {
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        } int w = a; w a a = c a c c = w c w w = b w b b = d b d d = w d w if(b < c){
            System.out.println(0);
        }
        else if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        } b < c b c {
            System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        } b>d b d {
            System.out.println(d-c);
        } System.out.println(d-c) System.out.println System.out System System.out d-c d c {
            System.out.println(b-c);
        } System.out.println(b-c) System.out.println System.out System System.out b-c b c 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){
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        }
        if(b < c){
            System.out.println(0);
        }
        else if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        }
	}
} 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){
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        }
        if(b < c){
            System.out.println(0);
        }
        else if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        }
	}
} 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){
          int w = a;
          a = c;
          c = w;
          w = b;
          b = d;
          d = w;
        }
        if(b < c){
            System.out.println(0);
        }
        else if(b>d){
            System.out.println(d-c);
        }else{
            System.out.println(b-c);
        }
	}
}
