"use strict"
const tan = (x) => { return Math.tan(x); }
function main(arg) {
    let [A,B,H,M] = arg.trim().split("\n")[0].split(" ").map(Number)
    const aTh = (H + M / 60) * 360 / 12
    const bTh = M * 360 / 60
    let th = Math.abs(aTh - bTh)
    // console.log(th)
    // th = 120
    console.log(solve(A,B,th))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function solve(a, b, th) {
    let c2 = Math.pow(a ,2) + Math.pow(b ,2) - 2 * a * b * Math.cos(th * (Math.PI / 180))
    return Math.sqrt(c2)
}