import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		
		int[] input = new int [4];
		
		for(int i = 0; i < 4; i++){
			input[i] = Integer.parseInt(strArray[i]);
		}
		
		int on = Math.max(input[0], input[2]);
		int off = Math.min(input[1], input[3]);
//		System.out.println("on "+on+" off "+off);
		
		System.out.println(Math.max(off-on, 0));
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		
		int[] input = new int [4];
		
		for(int i = 0; i < 4; i++){
			input[i] = Integer.parseInt(strArray[i]);
		}
		
		int on = Math.max(input[0], input[2]);
		int off = Math.min(input[1], input[3]);
//		System.out.println("on "+on+" off "+off);
		
		System.out.println(Math.max(off-on, 0));
	}

} Main /**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		
		int[] input = new int [4];
		
		for(int i = 0; i < 4; i++){
			input[i] = Integer.parseInt(strArray[i]);
		}
		
		int on = Math.max(input[0], input[2]);
		int off = Math.min(input[1], input[3]);
//		System.out.println("on "+on+" off "+off);
		
		System.out.println(Math.max(off-on, 0));
	} main {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		
		int[] input = new int [4];
		
		for(int i = 0; i < 4; i++){
			input[i] = Integer.parseInt(strArray[i]);
		}
		
		int on = Math.max(input[0], input[2]);
		int off = Math.min(input[1], input[3]);
//		System.out.println("on "+on+" off "+off);
		
		System.out.println(Math.max(off-on, 0));
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] strArray = br.readLine().split(" "); strArray br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int[] input = new int [4]; input new int [4] 4 for(int i = 0; i < 4; i++){
			input[i] = Integer.parseInt(strArray[i]);
		} int i = 0; int i = 0; i 0 i < 4 i 4 i++ i++ i {
			input[i] = Integer.parseInt(strArray[i]);
		} {
			input[i] = Integer.parseInt(strArray[i]);
		} input[i] = Integer.parseInt(strArray[i]) input[i] input i Integer.parseInt(strArray[i]) Integer.parseInt Integer strArray[i] strArray i int on = Math.max(input[0], input[2]); on Math.max(input[0], input[2]) Math.max Math input[0] input 0 input[2] input 2 int off = Math.min(input[1], input[3]); off Math.min(input[1], input[3]) Math.min Math input[1] input 1 input[3] input 3 System.out.println(Math.max(off-on, 0)) System.out.println System.out System System.out Math.max(off-on, 0) Math.max Math off-on off on 0 String[] args args public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		
		int[] input = new int [4];
		
		for(int i = 0; i < 4; i++){
			input[i] = Integer.parseInt(strArray[i]);
		}
		
		int on = Math.max(input[0], input[2]);
		int off = Math.min(input[1], input[3]);
//		System.out.println("on "+on+" off "+off);
		
		System.out.println(Math.max(off-on, 0));
	}

} public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		
		int[] input = new int [4];
		
		for(int i = 0; i < 4; i++){
			input[i] = Integer.parseInt(strArray[i]);
		}
		
		int on = Math.max(input[0], input[2]);
		int off = Math.min(input[1], input[3]);
//		System.out.println("on "+on+" off "+off);
		
		System.out.println(Math.max(off-on, 0));
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] strArray = br.readLine().split(" ");
		
		int[] input = new int [4];
		
		for(int i = 0; i < 4; i++){
			input[i] = Integer.parseInt(strArray[i]);
		}
		
		int on = Math.max(input[0], input[2]);
		int off = Math.min(input[1], input[3]);
//		System.out.println("on "+on+" off "+off);
		
		System.out.println(Math.max(off-on, 0));
	}

}
