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();
    boolean[] A = new boolean[101];
    boolean[] B = new boolean[101];
    for (int i = a; i < b; i++) {
      A[i] = true;
    }
    for (int i = c; i < d; i++) {
      B[i] = true;
    }

    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
} 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();
    boolean[] A = new boolean[101];
    boolean[] B = new boolean[101];
    for (int i = a; i < b; i++) {
      A[i] = true;
    }
    for (int i = c; i < d; i++) {
      B[i] = true;
    }

    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
} 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();
    boolean[] A = new boolean[101];
    boolean[] B = new boolean[101];
    for (int i = a; i < b; i++) {
      A[i] = true;
    }
    for (int i = c; i < d; i++) {
      B[i] = true;
    }

    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    }

    System.out.println(cnt);

  } main {

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int d = sc.nextInt();
    boolean[] A = new boolean[101];
    boolean[] B = new boolean[101];
    for (int i = a; i < b; i++) {
      A[i] = true;
    }
    for (int i = c; i < d; i++) {
      B[i] = true;
    }

    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    }

    System.out.println(cnt);

  } 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 boolean[] A = new boolean[101]; A new boolean[101] 101 boolean[] B = new boolean[101]; B new boolean[101] 101 for (int i = a; i < b; i++) {
      A[i] = true;
    } int i = a; int i = a; i a i < b i b i++ i++ i {
      A[i] = true;
    } {
      A[i] = true;
    } A[i] = true A[i] A i true for (int i = c; i < d; i++) {
      B[i] = true;
    } int i = c; int i = c; i c i < d i d i++ i++ i {
      B[i] = true;
    } {
      B[i] = true;
    } B[i] = true B[i] B i true int cnt = 0; cnt 0 for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    } int i = 0; int i = 0; i 0 i < 101 i 101 i++ i++ i {
      if (A[i] && B[i]) {
        cnt++;
      }
    } {
      if (A[i] && B[i]) {
        cnt++;
      }
    } if (A[i] && B[i]) {
        cnt++;
      } A[i] && B[i] A[i] A i B[i] B i {
        cnt++;
      } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt 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();
    boolean[] A = new boolean[101];
    boolean[] B = new boolean[101];
    for (int i = a; i < b; i++) {
      A[i] = true;
    }
    for (int i = c; i < d; i++) {
      B[i] = true;
    }

    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
} 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();
    boolean[] A = new boolean[101];
    boolean[] B = new boolean[101];
    for (int i = a; i < b; i++) {
      A[i] = true;
    }
    for (int i = c; i < d; i++) {
      B[i] = true;
    }

    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
} 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();
    boolean[] A = new boolean[101];
    boolean[] B = new boolean[101];
    for (int i = a; i < b; i++) {
      A[i] = true;
    }
    for (int i = c; i < d; i++) {
      B[i] = true;
    }

    int cnt = 0;
    for (int i = 0; i < 101; i++) {
      if (A[i] && B[i]) {
        cnt++;
      }
    }

    System.out.println(cnt);

  }
}