#include<stdio.h>
main()
{
	int A, B, C, D,xia,shang;
	while(scanf("%d%d%d%d",&A,&B,&C,&D)!=EOF)
	{
		xia=A;shang=D;
		if(B<=C)
		printf("0\n");
		else
		{
			if(C>xia)
			xia=C;
			if(B<shang)
			shang=B;
			printf("%d\n",shang-xia);
		}
		
	}
}