function Main(input) {
    var values = input.split(" ");
    var A = parseInt(values[0], 10);
    var B = parseInt(values[1], 10);
    var H = parseInt(values[2], 10);
    var M = parseInt(values[3], 10);
    var hpos = [
        A * Math.cos( (H + M / 60) * 30 * (Math.PI / 180) ),
        A * Math.sin( (H + M / 60) * 30 * (Math.PI / 180) )
    ];
    var mpos = [
        B * Math.cos( M * 6 * (Math.PI / 180) ),
        B * Math.sin( M * 6 * (Math.PI / 180) )
    ]
    var dist = Math.sqrt(
        Math.pow(hpos[0] - mpos[0], 2) +
        Math.pow(hpos[1] - mpos[1], 2)
    );
    console.log('%d', dist);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
