import java.util.*;

public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int n1 = Integer.parseInt(s[0]);
    int n2 = Integer.parseInt(s[1]);
    int n3 = Integer.parseInt(s[2]);
    int n4 = Integer.parseInt(s[3]);
    
    int st = 0;
    int en = 0;
    if(n1 > n3){
      st = n1;
    }else{
      st = n3;
    }
    
    if(n2 < n4){
      en = n2;
    }else{
      en = n4;
    }
    
    if(en -st > 0){
      System.out.println(en - st);
    }else{
      System.out.println(0);
    }
  }
} import java.util.*; util.* java public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int n1 = Integer.parseInt(s[0]);
    int n2 = Integer.parseInt(s[1]);
    int n3 = Integer.parseInt(s[2]);
    int n4 = Integer.parseInt(s[3]);
    
    int st = 0;
    int en = 0;
    if(n1 > n3){
      st = n1;
    }else{
      st = n3;
    }
    
    if(n2 < n4){
      en = n2;
    }else{
      en = n4;
    }
    
    if(en -st > 0){
      System.out.println(en - st);
    }else{
      System.out.println(0);
    }
  }
} Main public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int n1 = Integer.parseInt(s[0]);
    int n2 = Integer.parseInt(s[1]);
    int n3 = Integer.parseInt(s[2]);
    int n4 = Integer.parseInt(s[3]);
    
    int st = 0;
    int en = 0;
    if(n1 > n3){
      st = n1;
    }else{
      st = n3;
    }
    
    if(n2 < n4){
      en = n2;
    }else{
      en = n4;
    }
    
    if(en -st > 0){
      System.out.println(en - st);
    }else{
      System.out.println(0);
    }
  } main {
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int n1 = Integer.parseInt(s[0]);
    int n2 = Integer.parseInt(s[1]);
    int n3 = Integer.parseInt(s[2]);
    int n4 = Integer.parseInt(s[3]);
    
    int st = 0;
    int en = 0;
    if(n1 > n3){
      st = n1;
    }else{
      st = n3;
    }
    
    if(n2 < n4){
      en = n2;
    }else{
      en = n4;
    }
    
    if(en -st > 0){
      System.out.println(en - st);
    }else{
      System.out.println(0);
    }
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String[] s = sc.nextLine().split(" "); s sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int n1 = Integer.parseInt(s[0]); n1 Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 int n2 = Integer.parseInt(s[1]); n2 Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 int n3 = Integer.parseInt(s[2]); n3 Integer.parseInt(s[2]) Integer.parseInt Integer s[2] s 2 int n4 = Integer.parseInt(s[3]); n4 Integer.parseInt(s[3]) Integer.parseInt Integer s[3] s 3 int st = 0; st 0 int en = 0; en 0 if(n1 > n3){
      st = n1;
    }else{
      st = n3;
    } n1 > n3 n1 n3 {
      st = n1;
    } st = n1 st n1 {
      st = n3;
    } st = n3 st n3 if(n2 < n4){
      en = n2;
    }else{
      en = n4;
    } n2 < n4 n2 n4 {
      en = n2;
    } en = n2 en n2 {
      en = n4;
    } en = n4 en n4 if(en -st > 0){
      System.out.println(en - st);
    }else{
      System.out.println(0);
    } en -st > 0 en -st en st 0 {
      System.out.println(en - st);
    } System.out.println(en - st) System.out.println System.out System System.out en - st en st {
      System.out.println(0);
    } System.out.println(0) System.out.println System.out System System.out 0 String[]args args public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int n1 = Integer.parseInt(s[0]);
    int n2 = Integer.parseInt(s[1]);
    int n3 = Integer.parseInt(s[2]);
    int n4 = Integer.parseInt(s[3]);
    
    int st = 0;
    int en = 0;
    if(n1 > n3){
      st = n1;
    }else{
      st = n3;
    }
    
    if(n2 < n4){
      en = n2;
    }else{
      en = n4;
    }
    
    if(en -st > 0){
      System.out.println(en - st);
    }else{
      System.out.println(0);
    }
  }
} public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int n1 = Integer.parseInt(s[0]);
    int n2 = Integer.parseInt(s[1]);
    int n3 = Integer.parseInt(s[2]);
    int n4 = Integer.parseInt(s[3]);
    
    int st = 0;
    int en = 0;
    if(n1 > n3){
      st = n1;
    }else{
      st = n3;
    }
    
    if(n2 < n4){
      en = n2;
    }else{
      en = n4;
    }
    
    if(en -st > 0){
      System.out.println(en - st);
    }else{
      System.out.println(0);
    }
  }
} Main
import java.util.*;

public class Main{
  public static void main (String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int n1 = Integer.parseInt(s[0]);
    int n2 = Integer.parseInt(s[1]);
    int n3 = Integer.parseInt(s[2]);
    int n4 = Integer.parseInt(s[3]);
    
    int st = 0;
    int en = 0;
    if(n1 > n3){
      st = n1;
    }else{
      st = n3;
    }
    
    if(n2 < n4){
      en = n2;
    }else{
      en = n4;
    }
    
    if(en -st > 0){
      System.out.println(en - st);
    }else{
      System.out.println(0);
    }
  }
}