import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int start;
			int end;
			if(a < c){
				start = c;
       		}else{
                start = a;
        	}
      		if(b < d){
				end = b;
      		}else{
        		end = d;
      		}
      		if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            }
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int start;
			int end;
			if(a < c){
				start = c;
       		}else{
                start = a;
        	}
      		if(b < d){
				end = b;
      		}else{
        		end = d;
      		}
      		if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            }
	}
} Main public static void main(String[] args){
		Scanner s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int start;
			int end;
			if(a < c){
				start = c;
       		}else{
                start = a;
        	}
      		if(b < d){
				end = b;
      		}else{
        		end = d;
      		}
      		if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            }
	} main {
		Scanner s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int start;
			int end;
			if(a < c){
				start = c;
       		}else{
                start = a;
        	}
      		if(b < d){
				end = b;
      		}else{
        		end = d;
      		}
      		if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            }
	} Scanner s = new Scanner(System.in); s new Scanner(System.in) int a = s.nextInt(); a s.nextInt() s.nextInt s int b = s.nextInt(); b s.nextInt() s.nextInt s int c = s.nextInt(); c s.nextInt() s.nextInt s int d = s.nextInt(); d s.nextInt() s.nextInt s int start; start int end; end if(a < c){
				start = c;
       		}else{
                start = a;
        	} a < c a c {
				start = c;
       		} start = c start c {
                start = a;
        	} start = a start a if(b < d){
				end = b;
      		}else{
        		end = d;
      		} b < d b d {
				end = b;
      		} end = b end b {
        		end = d;
      		} end = d end d if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            } start < end start end {
				System.out.println(end - start);
      		} System.out.println(end - start) System.out.println System.out System System.out end - start end start {
				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 s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int start;
			int end;
			if(a < c){
				start = c;
       		}else{
                start = a;
        	}
      		if(b < d){
				end = b;
      		}else{
        		end = d;
      		}
      		if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            }
	}
} public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int start;
			int end;
			if(a < c){
				start = c;
       		}else{
                start = a;
        	}
      		if(b < d){
				end = b;
      		}else{
        		end = d;
      		}
      		if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            }
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int start;
			int end;
			if(a < c){
				start = c;
       		}else{
                start = a;
        	}
      		if(b < d){
				end = b;
      		}else{
        		end = d;
      		}
      		if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            }
	}
}