import java.util.*;

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 t = 0;
    for (double d = A + 0.5; d < B; d += 1.0) {
      if (C < d && d < D) t++;
    }
    System.out.println(t);
  }
} import java.util.*; util.* java 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 t = 0;
    for (double d = A + 0.5; d < B; d += 1.0) {
      if (C < d && d < D) t++;
    }
    System.out.println(t);
  }
} 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 t = 0;
    for (double d = A + 0.5; d < B; d += 1.0) {
      if (C < d && d < D) t++;
    }
    System.out.println(t);
  } main {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    int t = 0;
    for (double d = A + 0.5; d < B; d += 1.0) {
      if (C < d && d < D) t++;
    }
    System.out.println(t);
  } 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 t = 0; t 0 for (double d = A + 0.5; d < B; d += 1.0) {
      if (C < d && d < D) t++;
    } double d = A + 0.5; double d = A + 0.5; d A + 0.5 A 0.5 d < B d B d += 1.0 d += 1.0 d 1.0 {
      if (C < d && d < D) t++;
    } {
      if (C < d && d < D) t++;
    } if (C < d && d < D) t++; C < d && d < D C < d C d d < D d D t++ t System.out.println(t) System.out.println System.out System System.out t String[] args args
import java.util.*;

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 t = 0;
    for (double d = A + 0.5; d < B; d += 1.0) {
      if (C < d && d < D) t++;
    }
    System.out.println(t);
  }
}
