    import java.util.Scanner;
     
    class Main{
    	public static void main(String arg[]) {
    		Scanner sc = new Scanner(System.in);
    		int A = sc.nextInt();
    		int B = sc.nextInt();
    		int C = sc.nextInt();
    		int D = sc.nextInt();
    		sc.close();
    		int[] Alice = new int[102];
    		int[] Bob = new int[102];
    		int count = 0;
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			}
    		}
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} 
    		}
    		
    		for(int i = 0; i <= 100; i++) {
    			if(Alice[i] == Bob[i]) {
    				count++;
    			}
    		}
    		System.out.println(count);
    	}
    } import java.util.Scanner; Scanner java.util class Main{
    	public static void main(String arg[]) {
    		Scanner sc = new Scanner(System.in);
    		int A = sc.nextInt();
    		int B = sc.nextInt();
    		int C = sc.nextInt();
    		int D = sc.nextInt();
    		sc.close();
    		int[] Alice = new int[102];
    		int[] Bob = new int[102];
    		int count = 0;
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			}
    		}
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} 
    		}
    		
    		for(int i = 0; i <= 100; i++) {
    			if(Alice[i] == Bob[i]) {
    				count++;
    			}
    		}
    		System.out.println(count);
    	}
    } Main public static void main(String arg[]) {
    		Scanner sc = new Scanner(System.in);
    		int A = sc.nextInt();
    		int B = sc.nextInt();
    		int C = sc.nextInt();
    		int D = sc.nextInt();
    		sc.close();
    		int[] Alice = new int[102];
    		int[] Bob = new int[102];
    		int count = 0;
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			}
    		}
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} 
    		}
    		
    		for(int i = 0; i <= 100; i++) {
    			if(Alice[i] == Bob[i]) {
    				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();
    		sc.close();
    		int[] Alice = new int[102];
    		int[] Bob = new int[102];
    		int count = 0;
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			}
    		}
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} 
    		}
    		
    		for(int i = 0; i <= 100; i++) {
    			if(Alice[i] == Bob[i]) {
    				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 sc.close() sc.close sc int[] Alice = new int[102]; Alice new int[102] 102 int[] Bob = new int[102]; Bob new int[102] 102 int count = 0; count 0 for(int i = 0; i <= 100; i++ ) {
    			if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			}
    		} int i = 0; int i = 0; i 0 i <= 100 i 100 i++ i++ i {
    			if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			}
    		} {
    			if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			}
    		} if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			} i < A || i >= B i < A i A i >= B i B {
    				Alice[i] = 999;
    			} Alice[i] = 999 Alice[i] Alice i 999 {
    				Alice[i]= i; 
    			} Alice[i]= i Alice[i] Alice i i for(int i = 0; i <= 100; i++ ) {
    			if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} 
    		} int i = 0; int i = 0; i 0 i <= 100 i 100 i++ i++ i {
    			if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} 
    		} {
    			if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} 
    		} if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} i < C || i >= D i < C i C i >= D i D {
    				Bob[i] = 998;
    			} Bob[i] = 998 Bob[i] Bob i 998 {
    				Bob[i]= i; 
    			} Bob[i]= i Bob[i] Bob i i for(int i = 0; i <= 100; i++) {
    			if(Alice[i] == Bob[i]) {
    				count++;
    			}
    		} int i = 0; int i = 0; i 0 i <= 100 i 100 i++ i++ i {
    			if(Alice[i] == Bob[i]) {
    				count++;
    			}
    		} {
    			if(Alice[i] == Bob[i]) {
    				count++;
    			}
    		} if(Alice[i] == Bob[i]) {
    				count++;
    			} Alice[i] == Bob[i] Alice[i] Alice i Bob[i] Bob i {
    				count++;
    			} count++ count System.out.println(count) System.out.println System.out System System.out count String arg[] arg
    import java.util.Scanner;
     
    class Main{
    	public static void main(String arg[]) {
    		Scanner sc = new Scanner(System.in);
    		int A = sc.nextInt();
    		int B = sc.nextInt();
    		int C = sc.nextInt();
    		int D = sc.nextInt();
    		sc.close();
    		int[] Alice = new int[102];
    		int[] Bob = new int[102];
    		int count = 0;
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < A || i >= B) {
    				Alice[i] = 999;
    			}else {
    				Alice[i]= i; 
    			}
    		}
    		
    		for(int i = 0; i <= 100; i++ ) {
    			if( i < C || i >= D) {
    				Bob[i] = 998;
    			}else {
    				Bob[i]= i; 
    			} 
    		}
    		
    		for(int i = 0; i <= 100; i++) {
    			if(Alice[i] == Bob[i]) {
    				count++;
    			}
    		}
    		System.out.println(count);
    	}
    }