import java.util.*;
import static java.lang.Math.abs;
public class Main{
public static void main(String... args){
Scanner sc=new Scanner(System.in);
int[] x=new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
int[] tl=new int[101];
for(int i=0;i<101;i++){
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
}
int ans=0;
for(int i=0;i<101;i++){
if(tl[i]==2)ans++;
}
System.out.println(ans);
}
} import java.util.*; util.* java import static java.lang.Math.abs; import static java.lang.Math.abs; import static java.lang.Math.abs; public class Main{
public static void main(String... args){
Scanner sc=new Scanner(System.in);
int[] x=new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
int[] tl=new int[101];
for(int i=0;i<101;i++){
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
}
int ans=0;
for(int i=0;i<101;i++){
if(tl[i]==2)ans++;
}
System.out.println(ans);
}
} Main public static void main(String... args){
Scanner sc=new Scanner(System.in);
int[] x=new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
int[] tl=new int[101];
for(int i=0;i<101;i++){
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
}
int ans=0;
for(int i=0;i<101;i++){
if(tl[i]==2)ans++;
}
System.out.println(ans);
} main {
Scanner sc=new Scanner(System.in);
int[] x=new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
int[] tl=new int[101];
for(int i=0;i<101;i++){
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
}
int ans=0;
for(int i=0;i<101;i++){
if(tl[i]==2)ans++;
}
System.out.println(ans);
} Scanner sc=new Scanner(System.in); sc new Scanner(System.in) int[] x=new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()}; x new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()} int[] tl=new int[101]; tl new int[101] 101 for(int i=0;i<101;i++){
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
} int i=0; int i=0; i 0 i<101 i 101 i++ i++ i {
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
} {
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
} if(i>=x[0]&&i<x[1])tl[i]++; i>=x[0]&&i<x[1] i>=x[0] i x[0] x 0 i<x[1] i x[1] x 1 tl[i]++ tl[i] tl i if(i>=x[2]&&i<x[3])tl[i]++; i>=x[2]&&i<x[3] i>=x[2] i x[2] x 2 i<x[3] i x[3] x 3 tl[i]++ tl[i] tl i int ans=0; ans 0 for(int i=0;i<101;i++){
if(tl[i]==2)ans++;
} int i=0; int i=0; i 0 i<101 i 101 i++ i++ i {
if(tl[i]==2)ans++;
} {
if(tl[i]==2)ans++;
} if(tl[i]==2)ans++; tl[i]==2 tl[i] tl i 2 ans++ ans 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[] x=new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
int[] tl=new int[101];
for(int i=0;i<101;i++){
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
}
int ans=0;
for(int i=0;i<101;i++){
if(tl[i]==2)ans++;
}
System.out.println(ans);
}
} public class Main{
public static void main(String... args){
Scanner sc=new Scanner(System.in);
int[] x=new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
int[] tl=new int[101];
for(int i=0;i<101;i++){
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
}
int ans=0;
for(int i=0;i<101;i++){
if(tl[i]==2)ans++;
}
System.out.println(ans);
}
} Main
import java.util.*;
import static java.lang.Math.abs;
public class Main{
public static void main(String... args){
Scanner sc=new Scanner(System.in);
int[] x=new int[]{sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt()};
int[] tl=new int[101];
for(int i=0;i<101;i++){
if(i>=x[0]&&i<x[1])tl[i]++;
if(i>=x[2]&&i<x[3])tl[i]++;
}
int ans=0;
for(int i=0;i<101;i++){
if(tl[i]==2)ans++;
}
System.out.println(ans);
}
}
