import java.util.*;

public class Main {
	
  	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int a = Integer.valueOf(inputs[0]);
      	int b = Integer.valueOf(inputs[1]);
      	int c = Integer.valueOf(inputs[2]);
      	int d = Integer.valueOf(inputs[3]);
      	int start = 0; 
      	int stop = 0;
     	if(a>=c) {
          start = a;
        }
      	else {
          start = c;
        }
      
      if(b<=d) {
        stop = b;
      }
      else {
        stop = d;
      }
      
      if(start>=stop) {
        System.out.println("0");
      }
      else {
      	System.out.println(stop-start);
      }
      
      
      
      
      
    }

} import java.util.*; util.* java public class Main {
	
  	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int a = Integer.valueOf(inputs[0]);
      	int b = Integer.valueOf(inputs[1]);
      	int c = Integer.valueOf(inputs[2]);
      	int d = Integer.valueOf(inputs[3]);
      	int start = 0; 
      	int stop = 0;
     	if(a>=c) {
          start = a;
        }
      	else {
          start = c;
        }
      
      if(b<=d) {
        stop = b;
      }
      else {
        stop = d;
      }
      
      if(start>=stop) {
        System.out.println("0");
      }
      else {
      	System.out.println(stop-start);
      }
      
      
      
      
      
    }

} Main public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int a = Integer.valueOf(inputs[0]);
      	int b = Integer.valueOf(inputs[1]);
      	int c = Integer.valueOf(inputs[2]);
      	int d = Integer.valueOf(inputs[3]);
      	int start = 0; 
      	int stop = 0;
     	if(a>=c) {
          start = a;
        }
      	else {
          start = c;
        }
      
      if(b<=d) {
        stop = b;
      }
      else {
        stop = d;
      }
      
      if(start>=stop) {
        System.out.println("0");
      }
      else {
      	System.out.println(stop-start);
      }
      
      
      
      
      
    } main {
    	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int a = Integer.valueOf(inputs[0]);
      	int b = Integer.valueOf(inputs[1]);
      	int c = Integer.valueOf(inputs[2]);
      	int d = Integer.valueOf(inputs[3]);
      	int start = 0; 
      	int stop = 0;
     	if(a>=c) {
          start = a;
        }
      	else {
          start = c;
        }
      
      if(b<=d) {
        stop = b;
      }
      else {
        stop = d;
      }
      
      if(start>=stop) {
        System.out.println("0");
      }
      else {
      	System.out.println(stop-start);
      }
      
      
      
      
      
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) String input = sc.nextLine(); input sc.nextLine() sc.nextLine sc String[] inputs = input.split(" "); inputs input.split(" ") input.split input " " int a = Integer.valueOf(inputs[0]); a Integer.valueOf(inputs[0]) Integer.valueOf Integer inputs[0] inputs 0 int b = Integer.valueOf(inputs[1]); b Integer.valueOf(inputs[1]) Integer.valueOf Integer inputs[1] inputs 1 int c = Integer.valueOf(inputs[2]); c Integer.valueOf(inputs[2]) Integer.valueOf Integer inputs[2] inputs 2 int d = Integer.valueOf(inputs[3]); d Integer.valueOf(inputs[3]) Integer.valueOf Integer inputs[3] inputs 3 int start = 0; start 0 int stop = 0; stop 0 if(a>=c) {
          start = a;
        }
      	else {
          start = c;
        } a>=c a c {
          start = a;
        } start = a start a {
          start = c;
        } start = c start c if(b<=d) {
        stop = b;
      }
      else {
        stop = d;
      } b<=d b d {
        stop = b;
      } stop = b stop b {
        stop = d;
      } stop = d stop d if(start>=stop) {
        System.out.println("0");
      }
      else {
      	System.out.println(stop-start);
      } start>=stop start stop {
        System.out.println("0");
      } System.out.println("0") System.out.println System.out System System.out "0" {
      	System.out.println(stop-start);
      } System.out.println(stop-start) System.out.println System.out System System.out stop-start stop start String args[] args public class Main {
	
  	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int a = Integer.valueOf(inputs[0]);
      	int b = Integer.valueOf(inputs[1]);
      	int c = Integer.valueOf(inputs[2]);
      	int d = Integer.valueOf(inputs[3]);
      	int start = 0; 
      	int stop = 0;
     	if(a>=c) {
          start = a;
        }
      	else {
          start = c;
        }
      
      if(b<=d) {
        stop = b;
      }
      else {
        stop = d;
      }
      
      if(start>=stop) {
        System.out.println("0");
      }
      else {
      	System.out.println(stop-start);
      }
      
      
      
      
      
    }

} public class Main {
	
  	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int a = Integer.valueOf(inputs[0]);
      	int b = Integer.valueOf(inputs[1]);
      	int c = Integer.valueOf(inputs[2]);
      	int d = Integer.valueOf(inputs[3]);
      	int start = 0; 
      	int stop = 0;
     	if(a>=c) {
          start = a;
        }
      	else {
          start = c;
        }
      
      if(b<=d) {
        stop = b;
      }
      else {
        stop = d;
      }
      
      if(start>=stop) {
        System.out.println("0");
      }
      else {
      	System.out.println(stop-start);
      }
      
      
      
      
      
    }

} Main
import java.util.*;

public class Main {
	
  	public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
      	String input = sc.nextLine();
      	String[] inputs = input.split(" ");
      	int a = Integer.valueOf(inputs[0]);
      	int b = Integer.valueOf(inputs[1]);
      	int c = Integer.valueOf(inputs[2]);
      	int d = Integer.valueOf(inputs[3]);
      	int start = 0; 
      	int stop = 0;
     	if(a>=c) {
          start = a;
        }
      	else {
          start = c;
        }
      
      if(b<=d) {
        stop = b;
      }
      else {
        stop = d;
      }
      
      if(start>=stop) {
        System.out.println("0");
      }
      else {
      	System.out.println(stop-start);
      }
      
      
      
      
      
    }

}