import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int [4];
    for(int i = 0;i<4;i++){
      a[i] = sc.nextInt();
    }
    int an = Math.max(a[0],a[2]),bn = Math.min(a[1],a[3]);
    int ans = bn - an;
    if(ans < 0){
      ans = 0;
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int [4];
    for(int i = 0;i<4;i++){
      a[i] = sc.nextInt();
    }
    int an = Math.max(a[0],a[2]),bn = Math.min(a[1],a[3]);
    int ans = bn - an;
    if(ans < 0){
      ans = 0;
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int [4];
    for(int i = 0;i<4;i++){
      a[i] = sc.nextInt();
    }
    int an = Math.max(a[0],a[2]),bn = Math.min(a[1],a[3]);
    int ans = bn - an;
    if(ans < 0){
      ans = 0;
    }
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int a[] = new int [4];
    for(int i = 0;i<4;i++){
      a[i] = sc.nextInt();
    }
    int an = Math.max(a[0],a[2]),bn = Math.min(a[1],a[3]);
    int ans = bn - an;
    if(ans < 0){
      ans = 0;
    }
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a[] = new int [4]; a new int [4] 4 for(int i = 0;i<4;i++){
      a[i] = sc.nextInt();
    } int i = 0; int i = 0; i 0 i<4 i 4 i++ i++ i {
      a[i] = sc.nextInt();
    } {
      a[i] = sc.nextInt();
    } a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc int an = Math.max(a[0],a[2]) an Math.max(a[0],a[2]) Math.max Math a[0] a 0 a[2] a 2 bn = Math.min(a[1],a[3]); bn Math.min(a[1],a[3]) Math.min Math a[1] a 1 a[3] a 3 int ans = bn - an; ans bn - an bn an if(ans < 0){
      ans = 0;
    } ans < 0 ans 0 {
      ans = 0;
    } ans = 0 ans 0 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int [4];
    for(int i = 0;i<4;i++){
      a[i] = sc.nextInt();
    }
    int an = Math.max(a[0],a[2]),bn = Math.min(a[1],a[3]);
    int ans = bn - an;
    if(ans < 0){
      ans = 0;
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int [4];
    for(int i = 0;i<4;i++){
      a[i] = sc.nextInt();
    }
    int an = Math.max(a[0],a[2]),bn = Math.min(a[1],a[3]);
    int ans = bn - an;
    if(ans < 0){
      ans = 0;
    }
    System.out.println(ans);
  }
} Main
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int [4];
    for(int i = 0;i<4;i++){
      a[i] = sc.nextInt();
    }
    int an = Math.max(a[0],a[2]),bn = Math.min(a[1],a[3]);
    int ans = bn - an;
    if(ans < 0){
      ans = 0;
    }
    System.out.println(ans);
  }
}
