
function Main(input) {
    input = input.trim();
    input = input.split(" ")
    var a = input[0]
    var b = input[1]
    var h = input[2]
    var m = input[3]

    var c = h * 30 + m * 30/60;
    var d = m * 6;

    if(Math.abs(c-d) < 180){
        var theta = Math.abs(c-d)/180*Math.PI;
        console.log(Math.sqrt(
            a*a+b*b-2*a*b*Math.cos(theta)
        ))
    }else{
        var theta = (360-Math.abs(c-d))/180*Math.PI;
        console.log(Math.sqrt(
            a*a+b*b-2*a*b*Math.cos(theta)
        ))
    }
}

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