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();

    sc.close();

    int[] time = new int[102];

    time[A+1]++;
    time[B+1]--;
    time[C+1]++;
    time[D+1]--;

    for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    }

    int count = 0;

    for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    }

    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();

    sc.close();

    int[] time = new int[102];

    time[A+1]++;
    time[B+1]--;
    time[C+1]++;
    time[D+1]--;

    for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    }

    int count = 0;

    for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    }

    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();

    sc.close();

    int[] time = new int[102];

    time[A+1]++;
    time[B+1]--;
    time[C+1]++;
    time[D+1]--;

    for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    }

    int count = 0;

    for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    }

    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();

    sc.close();

    int[] time = new int[102];

    time[A+1]++;
    time[B+1]--;
    time[C+1]++;
    time[D+1]--;

    for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    }

    int count = 0;

    for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    }

    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 sc.close() sc.close sc int[] time = new int[102]; time new int[102] 102 time[A+1]++ time[A+1] time A+1 A 1 time[B+1]-- time[B+1] time B+1 B 1 time[C+1]++ time[C+1] time C+1 C 1 time[D+1]-- time[D+1] time D+1 D 1 for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    } int i = 2; int i = 2; i 2 i < 101 i 101 i++ i++ i {
      time[i] += time[i-1]; 
    } {
      time[i] += time[i-1]; 
    } time[i] += time[i-1] time[i] time i time[i-1] time i-1 i 1 int count = 0; count 0 for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    } int i = 1; int i = 1; i 1 i < 101 i 101 i++ i++ i {
      if (time[i] == 2) {
        count++;
      } 
    } {
      if (time[i] == 2) {
        count++;
      } 
    } if (time[i] == 2) {
        count++;
      } time[i] == 2 time[i] time i 2 {
        count++;
      } count++ 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();

    sc.close();

    int[] time = new int[102];

    time[A+1]++;
    time[B+1]--;
    time[C+1]++;
    time[D+1]--;

    for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    }

    int count = 0;

    for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    }

    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();

    sc.close();

    int[] time = new int[102];

    time[A+1]++;
    time[B+1]--;
    time[C+1]++;
    time[D+1]--;

    for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    }

    int count = 0;

    for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    }

    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();

    sc.close();

    int[] time = new int[102];

    time[A+1]++;
    time[B+1]--;
    time[C+1]++;
    time[D+1]--;

    for (int i = 2; i < 101; i++) {
      time[i] += time[i-1]; 
    }

    int count = 0;

    for (int i = 1; i < 101; i++) {
      if (time[i] == 2) {
        count++;
      } 
    }

    System.out.println(count);

  }

}