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();
		int s = 0, e = 0;
		
		if (A < C) {
			s = C;
		} else {
			s = A;
		}
		
		if (B < D) {
			e = B;
		} else {
			e = D;
		}
		
		if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		}

		sc.close();
	}
} 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();
		int s = 0, e = 0;
		
		if (A < C) {
			s = C;
		} else {
			s = A;
		}
		
		if (B < D) {
			e = B;
		} else {
			e = D;
		}
		
		if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		}

		sc.close();
	}
} 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();
		int s = 0, e = 0;
		
		if (A < C) {
			s = C;
		} else {
			s = A;
		}
		
		if (B < D) {
			e = B;
		} else {
			e = D;
		}
		
		if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		}

		sc.close();
	} main {
		Scanner sc = new Scanner((System.in));
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int s = 0, e = 0;
		
		if (A < C) {
			s = C;
		} else {
			s = A;
		}
		
		if (B < D) {
			e = B;
		} else {
			e = D;
		}
		
		if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		}

		sc.close();
	} 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 int s = 0 s 0 e = 0; e 0 if (A < C) {
			s = C;
		} else {
			s = A;
		} A < C A C {
			s = C;
		} s = C s C {
			s = A;
		} s = A s A if (B < D) {
			e = B;
		} else {
			e = D;
		} B < D B D {
			e = B;
		} e = B e B {
			e = D;
		} e = D e D if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		} (e - s) < 0 (e - s) e s 0 {
			System.out.print(0);
		} System.out.print(0) System.out.print System.out System System.out 0 {
			System.out.print((e-s));	
		} System.out.print((e-s)) System.out.print System.out System System.out (e-s) e s sc.close() sc.close sc 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();
		int s = 0, e = 0;
		
		if (A < C) {
			s = C;
		} else {
			s = A;
		}
		
		if (B < D) {
			e = B;
		} else {
			e = D;
		}
		
		if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		}

		sc.close();
	}
} 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();
		int s = 0, e = 0;
		
		if (A < C) {
			s = C;
		} else {
			s = A;
		}
		
		if (B < D) {
			e = B;
		} else {
			e = D;
		}
		
		if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		}

		sc.close();
	}
} 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();
		int s = 0, e = 0;
		
		if (A < C) {
			s = C;
		} else {
			s = A;
		}
		
		if (B < D) {
			e = B;
		} else {
			e = D;
		}
		
		if ((e - s) < 0) {
			System.out.print(0);
		} else {
			System.out.print((e-s));	
		}

		sc.close();
	}
}
