import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	public static long l=0,l2=0;
	public static void main(String[] args) throws IOException {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
		
	}

	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int A = in.nextInt();
		int B= in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int switchOnMax = Math.max(A, C);
		int switchOffMin = Math.min(B, D);
		if(switchOnMax < switchOffMin)
			out.println(switchOffMin - switchOnMax);
		else
			out.println(0);
		out.flush();
	}
}






class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			if(max>0) Arrays.fill(buf,0,max,(char)0);
			max = br.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.util.Arrays; Arrays java.util public class Main {
	public static long l=0,l2=0;
	public static void main(String[] args) throws IOException {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
		
	}

	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int A = in.nextInt();
		int B= in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int switchOnMax = Math.max(A, C);
		int switchOffMin = Math.min(B, D);
		if(switchOnMax < switchOffMin)
			out.println(switchOffMin - switchOnMax);
		else
			out.println(0);
		out.flush();
	}
} Main public static long l=0 l 0 l2=0; l2 0 public static void main(String[] args) throws IOException {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
		
	} main {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
		
	} l = System.currentTimeMillis() l System.currentTimeMillis() System.currentTimeMillis System new Main().exec() new Main().exec new Main() l2 = System.currentTimeMillis() l2 System.currentTimeMillis() System.currentTimeMillis System String[] args args public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int A = in.nextInt();
		int B= in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int switchOnMax = Math.max(A, C);
		int switchOffMin = Math.min(B, D);
		if(switchOnMax < switchOffMin)
			out.println(switchOffMin - switchOnMax);
		else
			out.println(0);
		out.flush();
	} exec {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int A = in.nextInt();
		int B= in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int switchOnMax = Math.max(A, C);
		int switchOffMin = Math.min(B, D);
		if(switchOnMax < switchOffMin)
			out.println(switchOffMin - switchOnMax);
		else
			out.println(0);
		out.flush();
	} InputUtil in = new InputUtil(); in new InputUtil() PrintWriter out = new PrintWriter(System.out); out new PrintWriter(System.out) int A = in.nextInt(); A in.nextInt() in.nextInt in int B= in.nextInt(); B in.nextInt() in.nextInt in int C = in.nextInt(); C in.nextInt() in.nextInt in int D = in.nextInt(); D in.nextInt() in.nextInt in int switchOnMax = Math.max(A, C); switchOnMax Math.max(A, C) Math.max Math A C int switchOffMin = Math.min(B, D); switchOffMin Math.min(B, D) Math.min Math B D if(switchOnMax < switchOffMin)
			out.println(switchOffMin - switchOnMax);
		else
			out.println(0); switchOnMax < switchOffMin switchOnMax switchOffMin out.println(switchOffMin - switchOnMax) out.println out switchOffMin - switchOnMax switchOffMin switchOnMax out.println(0) out.println out 0 out.flush() out.flush out class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			if(max>0) Arrays.fill(buf,0,max,(char)0);
			max = br.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

} InputUtil //Static Fields
	private static final int BUFSIZ = 100000; BUFSIZ 100000 //Fields
	protected InputStream in; in private char[] buf = null; buf null private int ptr = 0; ptr 0 private int max = -1; max -1 1 private BufferedReader br = null; br null //Constructors
	public InputUtil() {this(System.in,BUFSIZ);} InputUtil {this(System.in,BUFSIZ);} this(System.in,BUFSIZ) this System.in System System.in BUFSIZ public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	} InputUtil {
		initBuf(bufsiz);
		initIn(in);
	} initBuf(bufsiz) initBuf bufsiz initIn(in) initIn in InputStream in in int bufsiz bufsiz //Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));} initIn {br = new BufferedReader(new InputStreamReader(this.in = in));} br = new BufferedReader(new InputStreamReader(this.in = in)) br new BufferedReader(new InputStreamReader(this.in = in)) InputStream in in protected void initBuf(int bufsiz) {buf = new char[bufsiz];} initBuf {buf = new char[bufsiz];} buf = new char[bufsiz] buf new char[bufsiz] bufsiz int bufsiz bufsiz //buffer operation
	private void next() throws IOException {ptr++; readBuf();} next {ptr++; readBuf();} ptr++ ptr readBuf() readBuf private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			if(max>0) Arrays.fill(buf,0,max,(char)0);
			max = br.read(buf);
			ptr = 0;
		}
	} readBuf {
		if(ptr >= max && br.ready()) {
			if(max>0) Arrays.fill(buf,0,max,(char)0);
			max = br.read(buf);
			ptr = 0;
		}
	} if(ptr >= max && br.ready()) {
			if(max>0) Arrays.fill(buf,0,max,(char)0);
			max = br.read(buf);
			ptr = 0;
		} ptr >= max && br.ready() ptr >= max ptr max br.ready() br.ready br {
			if(max>0) Arrays.fill(buf,0,max,(char)0);
			max = br.read(buf);
			ptr = 0;
		} if(max>0) Arrays.fill(buf,0,max,(char)0); max>0 max 0 Arrays.fill(buf,0,max,(char)0) Arrays.fill Arrays buf 0 max (char)0 max = br.read(buf) max br.read(buf) br.read br buf ptr = 0 ptr 0 //Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; } isNum {return '0' <= b && b <= '9'; } return '0' <= b && b <= '9'; '0' <= b && b <= '9' '0' <= b '0' b b <= '9' b '9' char b b private boolean isMinus(char b) {return b=='-'; } isMinus {return b=='-'; } return b=='-'; b=='-' b '-' char b b private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	} _nextInt {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	} int sign = 1; sign 1 int res = 0; res 0 char c; c while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next(); !isNum(c=buf[ptr]) && !isMinus(c) !isNum(c=buf[ptr]) isNum(c=buf[ptr]) isNum c=buf[ptr] c buf[ptr] buf ptr !isMinus(c) isMinus(c) isMinus c next() next if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		} isMinus(buf[ptr]) isMinus buf[ptr] buf ptr {
			sign = -1;
			next();
		} sign = -1 sign -1 1 next() next while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		} isNum(c=buf[ptr]) isNum c=buf[ptr] c buf[ptr] buf ptr {
			res *= 10;
			res += c - '0' ;
			next();
		} res *= 10 res 10 res += c - '0' res c - '0' c '0' next() next next() next return sign * res; sign * res sign res public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	} nextInt {
		readBuf();
		return _nextInt();
	} readBuf() readBuf return _nextInt(); _nextInt() _nextInt public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	} nextInt {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	} readBuf() readBuf for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		} int i=0; int i=0; i 0 i<result.length i result.length result result.length i++ i++ i {
			result[i] = _nextInt();
		} {
			result[i] = _nextInt();
		} result[i] = _nextInt() result[i] result i _nextInt() _nextInt return result; result int[] result result //Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	} close {
		if(!this.in.equals(System.in)) 
			this.in.close();
	} if(!this.in.equals(System.in)) 
			this.in.close(); !this.in.equals(System.in) this.in.equals(System.in) this.in.equals this.in this this.in System.in System System.in this.in.close() this.in.close this.in this this.in public class Main {
	public static long l=0,l2=0;
	public static void main(String[] args) throws IOException {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
		
	}

	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int A = in.nextInt();
		int B= in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int switchOnMax = Math.max(A, C);
		int switchOffMin = Math.min(B, D);
		if(switchOnMax < switchOffMin)
			out.println(switchOffMin - switchOnMax);
		else
			out.println(0);
		out.flush();
	}
} public class Main {
	public static long l=0,l2=0;
	public static void main(String[] args) throws IOException {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
		
	}

	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int A = in.nextInt();
		int B= in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int switchOnMax = Math.max(A, C);
		int switchOffMin = Math.min(B, D);
		if(switchOnMax < switchOffMin)
			out.println(switchOffMin - switchOnMax);
		else
			out.println(0);
		out.flush();
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	public static long l=0,l2=0;
	public static void main(String[] args) throws IOException {
		l = System.currentTimeMillis();
		new Main().exec();
		l2 = System.currentTimeMillis();
		
	}

	public void exec() throws IOException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int A = in.nextInt();
		int B= in.nextInt();
		int C = in.nextInt();
		int D = in.nextInt();
		int switchOnMax = Math.max(A, C);
		int switchOffMin = Math.min(B, D);
		if(switchOnMax < switchOffMin)
			out.println(switchOffMin - switchOnMax);
		else
			out.println(0);
		out.flush();
	}
}






class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			if(max>0) Arrays.fill(buf,0,max,(char)0);
			max = br.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}