unittest
{
	assert( [ "0 75 25 100" ].parse.expand.solve == 50 );
	assert( [ "0 33 66 99" ].parse.expand.solve == 0 );
	assert( [ "10 90 20 80" ].parse.expand.solve == 60 );
	
	assert( [ "66 99 0 33" ].parse.expand.solve == 0 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abcd = input.front.split.to!( long[] );
	return tuple( abcd[ 0 ], abcd[ 1 ], abcd[ 2 ], abcd[ 3 ] );
}

auto solve( long a, long b, long c, long d )
{
	if( b <= c || d <= a ) return 0;
	else                   return min( b, d ) - max( a, c );
}
