unittest
{
	assert( [ "3 4 9 0" ].parse.expand.solve == "5.000000000" );
	assert( [ "3 4 10 40" ].parse.expand.solve == "4.564257194" );
}



import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

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

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

auto solve( real a, real b, real h, real m )
{
	auto ar = PI * ( h * 60 + m ) / ( 6.0L * 60 );		// 時針は時＋分で動く
	auto br = PI * m / 30.0L;
	auto ay = a * cos( ar );
	auto ax = a * sin( ar );
	auto by = b * cos( br );
	auto bx = b * sin( br );
	auto ans = ( ( ay - by ) ^^ 2.0L + ( ax - bx ) ^^ 2.0L ) ^^ 0.5L;
	return format( "%0.9f", ans );
}
