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();
      int count=0;
      int []hairetu = new int [B-A];
      int []hairetu2 = new int [D-C];
      for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      }
      for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      }
      for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  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();
      int count=0;
      int []hairetu = new int [B-A];
      int []hairetu2 = new int [D-C];
      for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      }
      for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      }
      for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  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();
      int count=0;
      int []hairetu = new int [B-A];
      int []hairetu2 = new int [D-C];
      for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      }
      for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      }
      for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  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();
      int count=0;
      int []hairetu = new int [B-A];
      int []hairetu2 = new int [D-C];
      for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      }
      for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      }
      for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  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 int count=0; count 0 int []hairetu = new int [B-A]; hairetu new int [B-A] B-A B A int []hairetu2 = new int [D-C]; hairetu2 new int [D-C] D-C D C for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      } int i=A+1; int i=A+1; i A+1 A 1 i<=B i B i++ i++ i {
    	  hairetu[i-A-1]=i;
      } {
    	  hairetu[i-A-1]=i;
      } hairetu[i-A-1]=i hairetu[i-A-1] hairetu i-A-1 i-A-1 i A 1 i for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      } int i=C+1; int i=C+1; i C+1 C 1 i<=D i D i++ i++ i {
    	  hairetu2[i-C-1]=i;
      } {
    	  hairetu2[i-C-1]=i;
      } hairetu2[i-C-1]=i hairetu2[i-C-1] hairetu2 i-C-1 i-C-1 i C 1 i for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  }
    	  }
      } int i=0; int i=0; i 0 i<B-A i B-A B A i++ i++ i {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  }
    	  }
      } {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  }
    	  }
      } for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  }
    	  } int j=0; int j=0; j 0 j<D-C j D-C D C j++ j++ j {
    		  if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  }
    	  } {
    		  if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  }
    	  } if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  } hairetu[i]==hairetu2[j] hairetu[i] hairetu i hairetu2[j] hairetu2 j {
    			  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();
      int count=0;
      int []hairetu = new int [B-A];
      int []hairetu2 = new int [D-C];
      for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      }
      for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      }
      for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  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();
      int count=0;
      int []hairetu = new int [B-A];
      int []hairetu2 = new int [D-C];
      for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      }
      for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      }
      for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  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();
      int count=0;
      int []hairetu = new int [B-A];
      int []hairetu2 = new int [D-C];
      for(int i=A+1;i<=B;i++) {
    	  hairetu[i-A-1]=i;
      }
      for(int i=C+1;i<=D;i++) {
    	  hairetu2[i-C-1]=i;
      }
      for(int i=0;i<B-A;i++) {
    	  for(int j=0;j<D-C;j++) {
    		  if(hairetu[i]==hairetu2[j]) {
    			  count++;
    		  }
    	  }
      }
      System.out.println(count);
	}
	}