import java.util.Scanner;
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){
         //0 30
         C = A;
      }else{
         A=C;
      }
      if(B >D){//20 60
         B=D;
      }else{
         D=B;
      }
      if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      }
   }
}
       import java.util.Scanner; Scanner 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){
         //0 30
         C = A;
      }else{
         A=C;
      }
      if(B >D){//20 60
         B=D;
      }else{
         D=B;
      }
      if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      }
   }
} 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){
         //0 30
         C = A;
      }else{
         A=C;
      }
      if(B >D){//20 60
         B=D;
      }else{
         D=B;
      }
      if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      }
   } 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){
         //0 30
         C = A;
      }else{
         A=C;
      }
      if(B >D){//20 60
         B=D;
      }else{
         D=B;
      }
      if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      }
   } 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){
         //0 30
         C = A;
      }else{
         A=C;
      } A >C A C {
         //0 30
         C = A;
      } C = A C A {
         A=C;
      } A=C A C if(B >D){//20 60
         B=D;
      }else{
         D=B;
      } B >D B D {//20 60
         B=D;
      } B=D B D {
         D=B;
      } D=B D B if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      } C>B C B {
         System.out.println(0);
      } System.out.println(0) System.out.println System.out System System.out 0 {
      System.out.println(B-A);
      } System.out.println(B-A) System.out.println System.out System System.out B-A B A 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){
         //0 30
         C = A;
      }else{
         A=C;
      }
      if(B >D){//20 60
         B=D;
      }else{
         D=B;
      }
      if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      }
   }
} 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){
         //0 30
         C = A;
      }else{
         A=C;
      }
      if(B >D){//20 60
         B=D;
      }else{
         D=B;
      }
      if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      }
   }
} Main
import java.util.Scanner;
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){
         //0 30
         C = A;
      }else{
         A=C;
      }
      if(B >D){//20 60
         B=D;
      }else{
         D=B;
      }
      if(C>B){
         System.out.println(0);
      }else{
      System.out.println(B-A);
      }
   }
}
      