"use strict";
const Main = input => {
    const inp = input.split(" ");
    const a = parseInt(inp[0], 10);//時針cm
    const b = parseInt(inp[1], 10);//分針cm
    const h = parseInt(inp[2], 10);//h時
    const m = parseInt(inp[3], 10);//m分

    let radh = 2 * Math.PI / 12 * (h % 12);
    let radm = 2 * Math.PI / 60 * m;

    let sign = 1;
    if(Math.PI < radh && radh < 2 * Math.PI) {
        radh = 2 * Math.PI - radh;
        sign *= -1;
    }
    if(Math.PI < radm && radm <= 2 * Math.PI) {
        radm = 2 * Math.PI - radm;
        sign *= -1;
    }

    const rad = Math.abs(radh - sign * radm);
    console.log(`radh: ${radh * 180 / Math.PI}, radm: ${radm * 180 / Math.PI}, rad: ${rad * 180 / Math.PI}`);
    const result = Math.sqrt(a ** 2 + b ** 2 - 2 * a * b * Math.cos(rad));

    console.log(result);
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));