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

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();
		int d= in.nextInt();
		int [] on= new int[110];
		for (int i = a; i < b; i++) {
			on[i]++;
		}
		for (int i = c; i < d; i++) {
			on[i]++;
		}
		int res=0;
		for (int i = 0; i < on.length; i++) {
			if(on[i]==2) res++;
		}
		System.out.println(res);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}
 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.ArrayDeque; ArrayDeque java.util import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();
		int d= in.nextInt();
		int [] on= new int[110];
		for (int i = a; i < b; i++) {
			on[i]++;
		}
		for (int i = c; i < d; i++) {
			on[i]++;
		}
		int res=0;
		for (int i = 0; i < on.length; i++) {
			if(on[i]==2) res++;
		}
		System.out.println(res);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
} Main public static ArrayList<String> s = new ArrayList<String>(); s new ArrayList<String>() public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();
		int d= in.nextInt();
		int [] on= new int[110];
		for (int i = a; i < b; i++) {
			on[i]++;
		}
		for (int i = c; i < d; i++) {
			on[i]++;
		}
		int res=0;
		for (int i = 0; i < on.length; i++) {
			if(on[i]==2) res++;
		}
		System.out.println(res);
	} main {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();
		int d= in.nextInt();
		int [] on= new int[110];
		for (int i = a; i < b; i++) {
			on[i]++;
		}
		for (int i = c; i < d; i++) {
			on[i]++;
		}
		int res=0;
		for (int i = 0; i < on.length; i++) {
			if(on[i]==2) res++;
		}
		System.out.println(res);
	} FastScanner in = new FastScanner(System.in); in new FastScanner(System.in) 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 [] on= new int[110]; on new int[110] 110 for (int i = a; i < b; i++) {
			on[i]++;
		} int i = a; int i = a; i a i < b i b i++ i++ i {
			on[i]++;
		} {
			on[i]++;
		} on[i]++ on[i] on i for (int i = c; i < d; i++) {
			on[i]++;
		} int i = c; int i = c; i c i < d i d i++ i++ i {
			on[i]++;
		} {
			on[i]++;
		} on[i]++ on[i] on i int res=0; res 0 for (int i = 0; i < on.length; i++) {
			if(on[i]==2) res++;
		} int i = 0; int i = 0; i 0 i < on.length i on.length on on.length i++ i++ i {
			if(on[i]==2) res++;
		} {
			if(on[i]==2) res++;
		} if(on[i]==2) res++; on[i]==2 on[i] on i 2 res++ res System.out.println(res) System.out.println System.out System System.out res String[] args args static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	} FastScanner BufferedReader br; br StringTokenizer st; st public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		} FastScanner {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		} br = new BufferedReader(new InputStreamReader(in)) br new BufferedReader(new InputStreamReader(in)) st = new StringTokenizer("") st new StringTokenizer("") InputStream in in public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		} nextDouble {
			return Double.parseDouble(next());
		} return Double.parseDouble(next()); Double.parseDouble(next()) Double.parseDouble Double next() next public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		} next {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		} if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			} !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st {
				st = new StringTokenizer(br.readLine());
				return next();
			} st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return next(); next() next return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() throws IOException {
			return Integer.parseInt(next());
		} nextInt {
			return Integer.parseInt(next());
		} return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() throws IOException {
			return Long.parseLong(next());
		} nextLong {
			return Long.parseLong(next());
		} return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();
		int d= in.nextInt();
		int [] on= new int[110];
		for (int i = a; i < b; i++) {
			on[i]++;
		}
		for (int i = c; i < d; i++) {
			on[i]++;
		}
		int res=0;
		for (int i = 0; i < on.length; i++) {
			if(on[i]==2) res++;
		}
		System.out.println(res);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
} public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();
		int d= in.nextInt();
		int [] on= new int[110];
		for (int i = a; i < b; i++) {
			on[i]++;
		}
		for (int i = c; i < d; i++) {
			on[i]++;
		}
		int res=0;
		for (int i = 0; i < on.length; i++) {
			if(on[i]==2) res++;
		}
		System.out.println(res);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int a= in.nextInt();
		int b= in.nextInt();
		int c= in.nextInt();
		int d= in.nextInt();
		int [] on= new int[110];
		for (int i = a; i < b; i++) {
			on[i]++;
		}
		for (int i = c; i < d; i++) {
			on[i]++;
		}
		int res=0;
		for (int i = 0; i < on.length; i++) {
			if(on[i]==2) res++;
		}
		System.out.println(res);
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}

