#include "stdafx.h"
#include <iostream> 
#include <algorithm> 
#include <cstring> 
#include <cstdio>
#include <vector> 
#include <queue> 
#include <cstdlib> 
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime> 
#include <map> 
#include <set> 
using namespace std;
#define lowbit(x) (x&(-x)) 
#define max(x,y) (x>y?x:y) 
#define min(x,y) (x<y?x:y) 
#define MAX 100000000000000000 
#define MOD 1000000007
#define pi acos(-1.0) 
#define ei exp(1) 
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int a, b, c, d;
int main()
{
	while (cin >> a >> b >> c >> d)
	{
		int ans = 0;
		for (int i = 0; i <= 100; i++)
		{
			if ((i >= a && i <= b) && (i >= c && i <= d))ans++;
		}
		printf("%d\n", ans - 1 >= 0 ? ans - 1 : 0);
	}
	return 0;
}
