import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    if(b<=c||d<=a){out.println(0);}else{
    out.println(abs(max(a,c)-min(b,d)));}
}
} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    if(b<=c||d<=a){out.println(0);}else{
    out.println(abs(max(a,c)-min(b,d)));}
}
} Main public static void main(String[] args){
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    if(b<=c||d<=a){out.println(0);}else{
    out.println(abs(max(a,c)-min(b,d)));}
} main {
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    if(b<=c||d<=a){out.println(0);}else{
    out.println(abs(max(a,c)-min(b,d)));}
} Scanner sc = new Scanner(in); sc new Scanner(in) int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int b = Integer.parseInt(sc.next()); b Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int c = Integer.parseInt(sc.next()); c Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int d = Integer.parseInt(sc.next()); d Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc if(b<=c||d<=a){out.println(0);}else{
    out.println(abs(max(a,c)-min(b,d)));} b<=c||d<=a b<=c b c d<=a d a {out.println(0);} out.println(0) out.println out 0 {
    out.println(abs(max(a,c)-min(b,d)));} out.println(abs(max(a,c)-min(b,d))) out.println out abs(max(a,c)-min(b,d)) abs max(a,c)-min(b,d) max(a,c) max a c min(b,d) min b d String[] args args public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    if(b<=c||d<=a){out.println(0);}else{
    out.println(abs(max(a,c)-min(b,d)));}
}
} public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    if(b<=c||d<=a){out.println(0);}else{
    out.println(abs(max(a,c)-min(b,d)));}
}
} Main
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
    int d = Integer.parseInt(sc.next());
    if(b<=c||d<=a){out.println(0);}else{
    out.println(abs(max(a,c)-min(b,d)));}
}
}