#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	while(cin>>a>>b>>c>>d)
	{
		if(c>b||d<a)
		{
			printf("0\n");
		}
		else
		{
			if(c<b&&c>a)
			{
				if(b<d)
				{
					printf("%d\n",b-c);
				}
				else
				{
					printf("%d\n",d-c);
				}
			}
			else
			{
				if(b<d)
				{
					printf("%d\n",b-a);
				}
				else
				{
					printf("%d\n",d-a);
				}
			}
		}
	}
	return 0;
}
 