import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(c <= a) {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		}
		//これでa<cである
		if(b <= c) {
			System.out.println(0);
			return;
		}
		if(b <= d) {
			System.out.println(b - c);
		} else {
			System.out.println(d - c);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(c <= a) {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		}
		//これでa<cである
		if(b <= c) {
			System.out.println(0);
			return;
		}
		if(b <= d) {
			System.out.println(b - c);
		} else {
			System.out.println(d - c);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(c <= a) {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		}
		//これでa<cである
		if(b <= c) {
			System.out.println(0);
			return;
		}
		if(b <= d) {
			System.out.println(b - c);
		} else {
			System.out.println(d - c);
		}
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(c <= a) {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		}
		//これでa<cである
		if(b <= c) {
			System.out.println(0);
			return;
		}
		if(b <= d) {
			System.out.println(b - c);
		} else {
			System.out.println(d - c);
		}
	} 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 if(c <= a) {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		} c <= a c a {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		} int w = a; w a a = c a c c = w c w int y = b; y b b = d b d d = y d y if(b <= c) {
			System.out.println(0);
			return;
		} b <= c b c {
			System.out.println(0);
			return;
		} System.out.println(0) System.out.println System.out System System.out 0 return; if(b <= d) {
			System.out.println(b - c);
		} else {
			System.out.println(d - c);
		} b <= d b d {
			System.out.println(b - c);
		} System.out.println(b - c) System.out.println System.out System System.out b - c b c {
			System.out.println(d - c);
		} System.out.println(d - c) System.out.println System.out System System.out d - c d c String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(c <= a) {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		}
		//これでa<cである
		if(b <= c) {
			System.out.println(0);
			return;
		}
		if(b <= d) {
			System.out.println(b - c);
		} else {
			System.out.println(d - c);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(c <= a) {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		}
		//これでa<cである
		if(b <= c) {
			System.out.println(0);
			return;
		}
		if(b <= d) {
			System.out.println(b - c);
		} else {
			System.out.println(d - c);
		}
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		if(c <= a) {
			int w = a;
			a = c;
			c = w;
			int y = b;
			b = d;
			d = y;
		}
		//これでa<cである
		if(b <= c) {
			System.out.println(0);
			return;
		}
		if(b <= d) {
			System.out.println(b - c);
		} else {
			System.out.println(d - c);
		}
	}
}