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();
    int count =0;
    boolean[] alice = new boolean[101];
    boolean[] bob = new boolean[101];
    for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    }
    if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    }
  }
} 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();
    int count =0;
    boolean[] alice = new boolean[101];
    boolean[] bob = new boolean[101];
    for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    }
    if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    }
  }
} 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();
    int count =0;
    boolean[] alice = new boolean[101];
    boolean[] bob = new boolean[101];
    for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    }
    if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    int count =0;
    boolean[] alice = new boolean[101];
    boolean[] bob = new boolean[101];
    for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    }
    if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    }
  } 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 count =0; count 0 boolean[] alice = new boolean[101]; alice new boolean[101] 101 boolean[] bob = new boolean[101]; bob new boolean[101] 101 for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    } int i=0; int i=0; i 0 i<=100 i 100 i++ i++ i {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    } {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    } if(i >= A && i <= B) alice[i] = true; i >= A && i <= B i >= A i A i <= B i B alice[i] = true alice[i] alice i true if(i >= C && i <= D) bob[i] = true; i >= C && i <= D i >= C i C i <= D i D bob[i] = true bob[i] bob i true if(alice[i] == true && bob[i] == true) count++; alice[i] == true && bob[i] == true alice[i] == true alice[i] alice i true bob[i] == true bob[i] bob i true count++ count if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    } count != 0 count 0 {
      System.out.println(count-1);
    } System.out.println(count-1) System.out.println System.out System System.out count-1 count 1 {
      System.out.println(count);
    } System.out.println(count) System.out.println System.out System System.out count 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();
    int count =0;
    boolean[] alice = new boolean[101];
    boolean[] bob = new boolean[101];
    for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    }
    if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    }
  }
} 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();
    int count =0;
    boolean[] alice = new boolean[101];
    boolean[] bob = new boolean[101];
    for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    }
    if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    }
  }
} 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();
    int count =0;
    boolean[] alice = new boolean[101];
    boolean[] bob = new boolean[101];
    for (int i=0; i<=100; i++) {
      if(i >= A && i <= B) alice[i] = true;
      if(i >= C && i <= D) bob[i] = true;
      if(alice[i] == true && bob[i] == true) count++;
    }
    if (count != 0) {
      System.out.println(count-1);
    } else {
      System.out.println(count);
    }
  }
}