"use strict";
var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.trim().split(/ |\n/), cid = 0;

function main() {
    let a = +cin.shift();//jisin
    let b = +cin.shift();//hunsin
    let h = +cin.shift();
    let m = +cin.shift();
    let theta =  Math.PI * ((h / 6 +m/360) - m / 30);
    let xx = a * a + b * b - 2 * a * b * Math.cos(theta);
    let x = Math.sqrt(xx);
    console.log(x);
}
main();