import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int A,B,C,D;
    int count = 0;

    A = s.nextInt();
    B = s.nextInt();
    C = s.nextInt();
    D = s.nextInt();
    for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    }
    //if(C <= A && D <= A)
    //if(C >= B && D >= B)
    //if()
    System.out.printf("%d",count);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int A,B,C,D;
    int count = 0;

    A = s.nextInt();
    B = s.nextInt();
    C = s.nextInt();
    D = s.nextInt();
    for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    }
    //if(C <= A && D <= A)
    //if(C >= B && D >= B)
    //if()
    System.out.printf("%d",count);
  }
} Main public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int A,B,C,D;
    int count = 0;

    A = s.nextInt();
    B = s.nextInt();
    C = s.nextInt();
    D = s.nextInt();
    for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    }
    //if(C <= A && D <= A)
    //if(C >= B && D >= B)
    //if()
    System.out.printf("%d",count);
  } main {
    Scanner s = new Scanner(System.in);
    int A,B,C,D;
    int count = 0;

    A = s.nextInt();
    B = s.nextInt();
    C = s.nextInt();
    D = s.nextInt();
    for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    }
    //if(C <= A && D <= A)
    //if(C >= B && D >= B)
    //if()
    System.out.printf("%d",count);
  } Scanner s = new Scanner(System.in); s new Scanner(System.in) int A A B B C C D; D int count = 0; count 0 A = s.nextInt() A s.nextInt() s.nextInt s B = s.nextInt() B s.nextInt() s.nextInt s C = s.nextInt() C s.nextInt() s.nextInt s D = s.nextInt() D s.nextInt() s.nextInt s for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    } int time = 0; int time = 0; time 0 time <= 100 time 100 time++ time++ time {
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    } {
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    } boolean ab = false ab false cd = false; cd false if(time >= A && time < B)ab = true; time >= A && time < B time >= A time A time < B time B ab = true ab true if(time >= C && time < D)cd = true; time >= C && time < D time >= C time C time < D time D cd = true cd true if(ab && cd)count++; ab && cd ab cd count++ count System.out.printf("%d",count) System.out.printf System.out System System.out "%d" count String[] args args public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int A,B,C,D;
    int count = 0;

    A = s.nextInt();
    B = s.nextInt();
    C = s.nextInt();
    D = s.nextInt();
    for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    }
    //if(C <= A && D <= A)
    //if(C >= B && D >= B)
    //if()
    System.out.printf("%d",count);
  }
} public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int A,B,C,D;
    int count = 0;

    A = s.nextInt();
    B = s.nextInt();
    C = s.nextInt();
    D = s.nextInt();
    for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    }
    //if(C <= A && D <= A)
    //if(C >= B && D >= B)
    //if()
    System.out.printf("%d",count);
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int A,B,C,D;
    int count = 0;

    A = s.nextInt();
    B = s.nextInt();
    C = s.nextInt();
    D = s.nextInt();
    for(int time = 0; time <= 100 ; time++){
      boolean ab = false,cd = false;
      if(time >= A && time < B)ab = true;
      if(time >= C && time < D)cd = true;
      if(ab && cd)count++;
    }
    //if(C <= A && D <= A)
    //if(C >= B && D >= B)
    //if()
    System.out.printf("%d",count);
  }
}
