#include<iostream>
using namespace std;
int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	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;
}