#include<iostream>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (0 <= a&&a <= b&&b <= 100 && 0 <= c&&c <= d&&d <= 100) {
		int max = a, min = b;
		if (a < c)
			max = c;
		if (b > d)
			min = d;
		int s = min - max;
		if (s > 0) {
			cout << s;
		}
		else
			cout << 0;
	}
   	return 0;
}