function Main(input)
{
	input = input.split(" ");
	for(var cnt = 0; cnt < input.length; cnt ++)
	{
		input[cnt] = parseFloat(input[cnt]);
	}

	var degH = (input[2] / 12.0 + input[3] / (12.0 * 60.0) - input[3] / 60.0) * Math.PI * 2;

	var ans = Math.pow(input[0], 2) + Math.pow(input[1], 2) - (2 * input[0] * input[1] ) * Math.cos(degH); 
	var ans = Math.sqrt(ans);
	
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));