function main(input) {
	input = input.split("\n");
  	input = input[0].split(" ");
  	let a = parseInt(input[0], 10);
  	let b = parseInt(input[1], 10);
  	let h = parseInt(input[2], 10);
  	let m = parseInt(input[3], 10);
  
  	console.log(
    	Math.sqrt(
        	a*a + b*b - 2*a*b*Math.cos(
            	2*Math.PI(
                	m/60 - h/12
                )
            )
        )
    );
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));